ALMaSS  1.0
The Animal, Landscape and Man Simulation System
farm.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
36 //
37 // farm.h
38 //
39 /*
40 
41 Copyright (c) 2003, National Environmental Research Institute, Denmark (NERI)
42 
43 All rights reserved.
44 
45 
46 Redistribution and use in source and binary forms, with or without
47 modification, are permitted provided that the following conditions are met:
48 
49 *) Redistributions of source code must retain the above copyright notice, this
50 list of conditions and the following disclaimer.
51 *) Redistributions in binary form must reproduce the above copyright notice,
52 this list of conditions and the following disclaimer in the documentation
53 and/or other materials provided with the distribution.
54 *) Neither the name of the NERI nor the names of its contributors
55 may be used to endorse or promote products derived from this software without
56 specific prior written permission.
57 
58 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
59 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
62 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
64 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
66 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
68 POSSIBILITY OF SUCH DAMAGE.
69 
70 */
71 
72 #ifndef FARM_H
73 #define FARM_H
74 
75 // This really needs to be a #define.
76 #define PROG_START 1
77 
78 
79 class Population_Manager;
80 class FarmManager;
81 class BroadBeans;
82 class Carrots;
83 class CloverGrassGrazed1;
84 class CloverGrassGrazed2;
85 class FieldPeas;
86 class FieldPeasSilage;
87 class Fodderbeet;
88 class FodderGrass;
89 class Maize;
90 class MaizeSilage;
91 class OMaizeSilage;
92 class OBarleyPeaCloverGrass;
93 class OCarrots;
94 class OCloverGrassGrazed1;
95 class OCloverGrassGrazed2;
96 class OCloverGrassSilage1;
97 class OFieldPeas;
98 class OFieldPeasSilage;
99 class OFirstYearDanger;
100 class OGrazingPigs;
101 class OOats;
102 class Oats;
103 class OrchardCrop;
104 class OFodderbeet;
105 class OPermanentGrassGrazed;
106 class OPotatoes;
107 class OSBarleySilage;
108 class OSeedGrass1;
109 class OSeedGrass2;
110 class OSpringBarley;
111 class OSpringBarleyExt;
112 class OSpringBarleyPigs;
113 class OWinterBarley;
114 class OWinterBarleyExt;
115 class OWinterRape;
116 class OWinterRye;
117 class OWinterWheatUndersown;
118 class OWinterWheatUndersownExt;
119 class PermanentGrassGrazed;
120 class PermanentGrassLowYield;
121 class PermanentGrassTussocky;
122 class PermanentSetAside;
123 class Potatoes;
124 class PotatoesIndustry;
125 class SeedGrass1;
126 class SeedGrass2;
127 class SetAside;
128 class SpringBarley;
129 class SpringBarleySpr;
130 class SpringBarleyPTreatment;
131 class SpringBarleySKManagement;
132 class SpringBarleyCloverGrass;
133 class SpringBarleySeed;
134 class SpringBarleySilage;
135 class SpringRape;
136 class Sugarbeet;
137 class Triticale;
138 class OTriticale;
139 class WinterBarley;
140 class WinterRape;
141 class WinterRye;
142 class WinterWheat;
143 class WWheatPControl;
144 class WWheatPTreatment;
145 class WWheatPToxicControl;
146 class AgroChemIndustryCereal;
147 class WinterWheatStrigling;
148 class WinterWheatStriglingSingle;
149 class WinterWheatStriglingCulm;
150 class SpringBarleyCloverGrassStrigling;
151 class SpringBarleyStrigling;
152 class SpringBarleyStriglingCulm;
153 class SpringBarleyStriglingSingle;
154 class MaizeStrigling;
155 class WinterRapeStrigling;
156 class WinterRyeStrigling;
157 class WinterBarleyStrigling;
158 class FieldPeasStrigling;
159 class SpringBarleyPeaCloverGrassStrigling;
160 class YoungForestCrop;
161 class Hunter;
162 class OWinterWheat;
163 class NorwegianPotatoes;
164 class NorwegianOats;
165 class NorwegianSpringBarley;
166 
167 class PLWinterWheat;
168 class PLWinterRape;
169 class PLWinterBarley;
170 class PLWinterTriticale;
171 class PLWinterRye;
172 class PLSpringWheat;
173 class PLSpringBarley;
174 class PLMaize;
175 class PLMaizeSilage;
176 class PLPotatoes;
177 class PLBeet;
178 class PLFodderLucerne1;
179 class PLFodderLucerne2;
180 class PLCarrots;
181 class PLSpringBarleySpr;
182 class PLWinterWheatLate;
183 class PLBeetSpr;
184 class PLBeans;
185 
186 class NLBeet;
187 class NLCarrots;
188 class NLMaize;
189 class NLPotatoes;
190 class NLSpringBarley;
191 class NLWinterWheat;
192 class NLCabbage;
193 class NLTulips;
194 class NLGrassGrazed1;
195 class NLGrassGrazed1Spring;
196 class NLGrassGrazed2;
197 class NLGrassGrazedLast;
198 class NLPermanentGrassGrazed;
199 class NLBeetSpring;
200 class NLCarrotsSpring;
201 class NLMaizeSpring;
202 class NLPotatoesSpring;
203 class NLSpringBarleySpring;
204 class NLCabbageSpring;
205 class NLCatchPeaCrop;
206 
207 class DummyCropPestTesting;
208 
209 
210 typedef vector<unsigned >polylist;
211 typedef vector < Hunter* > HunterList;
212 
218 };
219 
220 
221 typedef enum
222 {
275 
276 
277 //enums for the OptimisingFarms: toof, tos, tofs, toa, toc, top, tolp, tocv
278 typedef enum {
282  toof_Pig, // 3
283  toof_Foobar // Must be in here and the last one as well!
285 
286 typedef enum {
287  tos_Sand = 0,
288  tos_Other, // 1
289  tos_Clay, // 2
290  tos_Foobar // Must be in here and the last one as well!
292 
293 typedef enum {
296  tofs_Foobar // Must be in here and the last one as well!
298 
299 typedef enum {
301  toa_DCow, // 1
320  toa_Foobar // Must be in here and the last one as well!
322 
323 typedef enum {
325  toc_Oats, //1
329  toc_WRye, //5
334  toc_Peas, //10
367  toc_Foobar // Must be in here and the last one as well!
369 
370 //crop parameters that do not vary with farm type, soil type etc.
371 typedef enum {
389  top_Foobar // Must be in here and the last one as well!
391 
392 typedef enum {
396  tolp_Foobar // Must be in here and the last one as well!
398 
399 typedef enum {
416  tocv_Foobar // Must be in here and the last one as well!
418 
421 {
422  ppp_1 = 0,
432  ppp_foobar
433 };
434 
440 };
441 
444  bool m_present;
445 };
446 
448 struct PermCropData {
450  int Pct;
451 };
452 
454 struct tpct {
455  int index;
456  int pct;
457 };
458 
463 struct FarmEvent
464 {
465  bool m_lock;
468  long m_run;
469  int m_todo;
473 
474  FarmEvent( TTypesOfVegetation a_event, LE *a_field, int a_todo, long a_run,
475  bool a_lock, int a_start, bool a_first_year,
476  TTypesOfVegetation a_nextcrop )
477  {
478  m_event = a_event;
479  m_field = a_field;
480  m_todo = a_todo;
481  m_run = a_run;
482  m_lock = a_lock;
483  m_startday = a_start;
484  m_first_year = a_first_year;
485  m_next_tov=a_nextcrop;
486  }
487 };
488 
493 struct farminfo {
504 };
505 
506 
511 {
512 public:
514  int refID;
516  int homeX;
518  int homeY;
520  vector<int> FarmHuntRef;
522  vector<int> CheckedFarms;
523 
525  FarmHuntRef.resize( 0 );
526  CheckedFarms.resize( 0 );
527  }
528 };
529 
534 class Crop
535 {
536 protected:
541  int m_count;
544  //* \brief Contains information on whether this is a winter crop, spring crop, or catch crop that straddles the year boundary (0,1,2)
546 
551  void SimpleEvent(long a_date, int a_todo, bool a_lock);
552 
557  void SimpleEvent_(long a_date, int a_todo, bool a_lock, Farm* a_farm, LE* a_field);
558 
559 public:
560  virtual ~Crop() {}
561  Crop();
562  int GetFirstDate( void ) { return m_first_date; }
563  virtual bool Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev );
565  void ChooseNextCrop (int a_no_dates);
566  //* \brief Get method for m_CropClassification */
568  //* \brief Get method for m_CropClassification */
569  void SetCropClassification(int a_classification) { m_CropClassification = a_classification; }
570 
571 };
572 
573 
576 // v. similar to PermCropData, but has double instead of int.
577 //Used originally for saving Bedriftsmodel (original farm optimization model) type crops in almass type. Also used to store data on biomass_factors
578 //so changed the name of the member - from Pct to Number
579 
580  struct AlmassCrop {
581  double Number;
583  };
584 
590 
591 public:
593 
594  //Data at a general level
595  void Set_livestockTypes(TTypesOfAnimals livestock_type){m_livestockTypes.push_back(livestock_type);};
596  void Set_cropTypes(TTypesOfCrops crop_type){m_cropTypes.push_back(crop_type);};
597  void Set_cropTypes_str (string crop_type){m_str_cropTypes.push_back(crop_type);};
599  string Get_cropTypes_str (int i) {return m_str_cropTypes[i];};
601 
602  //Individual data for farms (vector size is no_farms x given_Foobar)
603  void Set_livestockNumber(int a_number){m_livestockNumbers.push_back(a_number);};
604  void Set_cropArea(double a_area){m_cropAreas.push_back(a_area);};
605  int Get_livestockNumber(int index){return m_livestockNumbers[index];};
606  int Get_livestockNumbersSize(){return (int)m_livestockNumbers.size();};
607  double Get_cropArea(int index){return m_cropAreas[index];};
608  int Get_cropAreasSize(){return (int)m_cropAreas.size();};
609 
610  //Data for farms
612  TTypesOfOptFarms Get_farmType (int a_almass_no);
613  void Set_winterMax (int a_value, int i){m_winterMax[i]=a_value;};
614  int Get_winterMax (int i) {return m_winterMax[i];};
615 
616  //Data for livestock
617  void Set_livestockParameter(double a_value, int i){m_livestockParameters[i]=a_value;};
619 
620  //Data for crops
621  void Set_cropParameter (double a_value, int i){m_cropParameters[i]=a_value;};
622  double Get_cropParameter (int i) {return m_cropParameters[i];};
623 
624  void Set_alfa (double a_value, int i){m_alfa[i]=a_value;};
625  double Get_alfa (int i) {return m_alfa[i];};
626  void Set_beta1 (double a_value, int i){m_beta1[i]=a_value;};
627  double Get_beta1 (int i) {return m_beta1[i];};
628  void Set_beta2 (double a_value, int i){m_beta2[i]=a_value;};
629  double Get_beta2 (int i) {return m_beta2[i];};
630  void Set_Nnorm (double a_value, int i){m_Nnorm[i]=a_value;};
631  double Get_Nnorm (int i) {return m_Nnorm[i];};
632 
633 
634  void Set_fixed (string a_value, int i){
635  if(a_value=="yes" || a_value=="YES" || a_value=="Yes" || a_value=="1"){m_fixed[i]=true;}
636  else {m_fixed[i]=false;}
637  };
638  bool Get_fixed (int i) {return m_fixed[i];};
639  void Set_fodder (string a_value, int i){
640  if(a_value=="yes" || a_value=="YES" || a_value=="Yes" || a_value=="1"){m_fodder[i]=true;}
641  else {m_fodder[i]=false;}
642  };
643  bool Get_fodder (int i) {return m_fodder[i];};
644  void Set_FUKey (double a_value, int i){m_FUKey[i]=a_value;};
645  double Get_FUKey (int i) {return m_FUKey[i];};
646 
647  void Set_sellingPrice (double a_value, int i){m_sellingPrice[i]=a_value;};
648  double Get_sellingPrice (int i) {return m_sellingPrice[i];};
649  void Set_sellingPrice_lastyr (double a_value, int i){m_sellingPrice_lastyr[i]=a_value;};
650  double Get_sellingPrice_lastyr (int i) {return m_sellingPrice_lastyr[i];};
651 
652  void Set_rotationMax (double a_value, int i){m_rotationMax[i]=a_value;};
653  double Get_rotationMax (int i) {return m_rotationMax[i];};
654  void Set_rotationMin (double a_value, int i){m_rotationMin[i]=a_value;};
655  double Get_rotationMin (int i) {return m_rotationMin[i];};
656 
657 
658  //versions for almass crops
659  void Set_biomass_factor (double a_value, int i){m_biomass_factors[i] = a_value;};
660  double Get_biomass_factor (int i) { return m_biomass_factors[i];}
661 
662  void Set_cropTypes_almass(TTypesOfVegetation crop_type){m_cropTypes_almass.push_back(crop_type);};
664  int Get_cropTypes_almass_size (){return (int)m_cropTypes_almass.size();};
665  void Set_cropTypes_almass_str (string crop_type){m_str_cropTypes_almass.push_back(crop_type);};
667 
668  void Set_noCrops (int no) {m_noCrops = no;};
669  int Get_noCrops (){return m_noCrops;};
670 
671  void Set_emaize_price (double a_value){m_energy_maize_price.push_back(a_value);};
672  double Get_emaize_price (int i){return m_energy_maize_price[i];};
673 
675  class FarmData{
676  public:
683  };
684 
685  vector<FarmData*>m_farm_data;
686 
687 
688 protected:
689  //called in the constructor
691  void InitializeVector(vector<double>&vector);
693  int m_noCrops; //how many crops will be optimised - the number is taken from one of the input files; it has to be the same in all input files with crop data!
694 
695 //I. Data at a general level - changed to config variables
696 
697 //II. Data for farms
698 
700  vector<string>m_str_cropTypes; //used in output function
702  vector<TTypesOfCrops>m_cropTypes;
703  //for almass crop types
705  vector<string>m_str_cropTypes_almass;
707  vector<TTypesOfVegetation>m_cropTypes_almass;
709  vector<TTypesOfAnimals>m_livestockTypes;
711  vector<double>m_cropAreas;
713  vector<int>m_livestockNumbers;
714 
716  vector<int>m_winterMax;
717 
718 //III. Data for livestock
720  vector<double>m_livestockParameters; //full list of the parameters - enum declaration (TTypesOfLivestockParameters)
721 
722 //IV. Data for crops
723  //1. parameters that do not vary with farm type, soil type etc. (number of parameters = top_Foobar !)
725  vector<double>m_cropParameters; //full list of the parameters - enum declaration (enum TTypesOfParameters)
726  //2. parameters that vary with a soil type
728  vector<double>m_alfa;
730  vector<double>m_beta1;
732  vector<double>m_beta2;
734  vector<double>m_Nnorm;
737  vector<double>m_biomass_factors;
738 
739  //3. parameters that vary with a farm type
741  vector<bool>m_fixed;
743  vector<bool>m_fodder;
745  vector<double>m_FUKey;
746  //4. parameters that vary with a farm and soil type
748  vector<double>m_sellingPrice;
750  vector<double>m_sellingPrice_lastyr;
751  //5. parameters that vary with a farm type, farm size and a soil type
753  vector<double>m_rotationMax;
755  vector<double>m_rotationMin;
756 
757  //6. Energy maize runs
759  vector<double>m_energy_maize_price;
760 
761 };
762 
767 class Farm
768 {
769 public:
770  // Management() will use the global date.
771  virtual void Management( void );
772 
773  // InitiateManagement() must be called after all the fields have
774  // been added to the farm.
775  virtual void InitiateManagement( void );
776 
777  void AddField( LE* a_newfield );
778  void RemoveField( LE* a_field );
779  Farm( FarmManager* a_manager );
780  virtual ~Farm( void );
781  void SetFarmNumber( int a_farm_num ) { m_farm_num = a_farm_num; }
782  int GetFarmNumber( void ) { return m_farm_num; }
783  //TTypesOfVegetation TranslateCropCodes(std::string& str); 19.03.13 - moved to farm manager
784  virtual bool Spraying_herbicides(TTypesOfVegetation){return true; };
785  virtual bool Spraying_fungins(TTypesOfVegetation){return true; };
786  virtual double Prob_multiplier (){return 1;};
787  void Assign_rotation(vector<TTypesOfVegetation>a_new_rotation);
788 
790  polylist* ListOpenFields( int a_openness ); //14.01.13
792  void Centroids();
794  int GetNoFields() { return (int) m_fields.size(); }
796  int GetNoOpenFields(int a_openness);
798  int GetAreaOpenFields(int a_openness);
800  APoint GetValidCoords() { APoint pt; pt.m_x = m_fields[0]->GetValidX(); pt.m_y = m_fields[0]->GetValidY(); return pt; }
803  {
804  int op = 0;
805  for (int i = 0; i < m_fields.size(); i++)
806  {
807  int openness = m_fields[i]->GetOpenness();
808  if (openness > op) op = openness;
809  }
810  return op;
811  }
812 
813  // And (*sigh*) the crop treatment functions... :-)
814  virtual bool SleepAllDay( LE *a_field, double a_user, int a_days );
815  virtual bool AutumnPlough( LE *a_field, double a_user, int a_days );
816  virtual bool StubblePlough(LE *a_field, double a_user, int a_days);
817  virtual bool StubbleCultivatorHeavy(LE *a_field, double a_user, int a_days);
818  virtual bool AutumnHarrow( LE *a_field, double a_user, int a_days );
819  virtual bool AutumnRoll( LE *a_field, double a_user, int a_days );
820  virtual bool PreseedingCultivator(LE *a_field, double a_user, int a_days);
821  virtual bool PreseedingCultivatorSow(LE *a_field, double a_user, int a_days);
822  virtual bool AutumnSow( LE *a_field, double a_user, int a_days );
823  virtual bool WinterPlough( LE *a_field, double a_user, int a_days );
824  virtual bool DeepPlough( LE *a_field, double a_user, int a_days );
825  virtual bool SpringPlough( LE *a_field, double a_user, int a_days );
826  virtual bool SpringHarrow( LE *a_field, double a_user, int a_days );
827  virtual bool SpringRoll( LE *a_field, double a_user, int a_days );
828  virtual bool SpringSow( LE *a_field, double a_user, int a_days );
829  virtual bool SpringSowWithFerti(LE *a_field, double a_user, int a_days);
830  virtual bool HerbicideTreat( LE *a_field, double a_user, int a_days );
831  virtual bool GrowthRegulator( LE *a_field, double a_user, int a_days );
832  virtual bool FungicideTreat( LE *a_field, double a_user, int a_days );
833  virtual bool InsecticideTreat( LE *a_field, double a_user, int a_days );
834  virtual bool ProductApplication(LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp);
835  virtual bool ProductApplication_DateLimited(LE * a_field, double, int, double a_applicationrate, PlantProtectionProducts a_ppp);
836  virtual bool Molluscicide( LE *a_field, double a_user, int a_days );
837  virtual bool RowCultivation( LE *a_field, double a_user, int a_days );
838  virtual bool Strigling( LE *a_field, double a_user, int a_days );
839  virtual bool StriglingSow( LE *a_field, double a_user, int a_days );
840  virtual bool StriglingHill(LE *a_field, double a_user, int a_days);
841  virtual bool HillingUp( LE *a_field, double a_user, int a_days );
842  virtual bool Water( LE *a_field, double a_user, int a_days );
843  virtual bool Swathing( LE *a_field, double a_user, int a_days );
844  virtual bool Harvest(LE *a_field, double a_user, int a_days);
845  virtual bool HarvestLong(LE *a_field, double a_user, int a_days);
846  virtual bool CattleOut(LE *a_field, double a_user, int a_days);
847  virtual bool CattleOutLowGrazing( LE *a_field, double a_user, int a_days );
848  virtual bool CattleIsOut( LE *a_field, double a_user, int a_days, int a_max );
849  virtual bool CattleIsOutLow( LE *a_field, double a_user, int a_days, int a_max );
850  virtual bool PigsOut( LE *a_field, double a_user, int a_days );
851  virtual bool PigsAreOut( LE *a_field, double a_user, int a_days );
852  virtual bool PigsAreOutForced( LE *a_field, double a_user, int a_days );
853  virtual bool CutToHay( LE *a_field, double a_user, int a_days );
854  virtual bool CutWeeds( LE *a_field, double a_user, int a_days );
855  virtual bool CutToSilage( LE *a_field, double a_user, int a_days );
856  virtual bool CutOrch( LE *a_field, double a_user, int a_days ); //added 27.08.12
857  virtual bool StrawChopping( LE *a_field, double a_user, int a_days );
858  virtual bool HayTurning( LE *a_field, double a_user, int a_days );
859  virtual bool HayBailing( LE *a_field, double a_user, int a_days );
860  virtual bool BurnStrawStubble( LE *a_field, double a_user, int a_days );
861  virtual bool StubbleHarrowing( LE *a_field, double a_user, int a_days );
862  virtual bool FP_NPKS( LE *a_field, double a_user, int a_days );
863  virtual bool FP_NPK( LE *a_field, double a_user, int a_days );
864  virtual bool FP_PK( LE *a_field, double a_user, int a_days );
865  virtual bool FP_LiquidNH3( LE *a_field, double a_user, int a_days );
866  virtual bool FP_Slurry( LE *a_field, double a_user, int a_days );
867  virtual bool FP_ManganeseSulphate( LE *a_field, double a_user, int a_days );
868  virtual bool FP_AmmoniumSulphate(LE *a_field, double a_user, int a_days);
869  virtual bool FP_Manure( LE *a_field, double a_user, int a_days );
870  virtual bool FP_GreenManure( LE *a_field, double a_user, int a_days );
871  virtual bool FP_Sludge( LE *a_field, double a_user, int a_days );
872  virtual bool FP_RSM(LE *a_field, double a_user, int a_days);
873  virtual bool FP_Calcium(LE *a_field, double a_user, int a_days);
874  virtual bool FA_NPKS(LE *a_field, double a_user, int a_days);
875  virtual bool FA_NPK( LE *a_field, double a_user, int a_days );
876  virtual bool FA_PK( LE *a_field, double a_user, int a_days );
877  virtual bool FA_Slurry( LE *a_field, double a_user, int a_days );
878  virtual bool FA_ManganeseSulphate(LE *a_field, double a_user, int a_days);
879  virtual bool FA_AmmoniumSulphate( LE *a_field, double a_user, int a_days );
880  virtual bool FA_Manure( LE *a_field, double a_user, int a_days );
881  virtual bool FA_GreenManure( LE *a_field, double a_user, int a_days );
882  virtual bool FA_Sludge( LE *a_field, double a_user, int a_days );
883  virtual bool FA_RSM(LE *a_field, double a_user, int a_days);
884  virtual bool FA_Calcium(LE *a_field, double a_user, int a_days);
885  virtual bool Biocide(LE *a_field, double a_user, int a_days);
886  virtual bool BedForming(LE *a_field, double a_user, int a_days);
887  virtual bool ShallowHarrow(LE *a_field, double a_user, int a_days);
888  virtual bool HeavyCultivatorAggregate(LE *a_field, double a_user, int a_days);
889  virtual bool FlowerCutting(LE *a_field, double a_user, int a_days);
890  virtual bool BulbHarvest(LE *a_field, double a_user, int a_days);
891  virtual bool StrawCovering(LE *a_field, double a_user, int a_days);
892  virtual bool StrawRemoval(LE *a_field, double a_user, int a_days);
893 
894  // User functions for the treatment steps:
895  void AddNewEvent( TTypesOfVegetation a_event, long a_date,
896  LE *a_field, int a_todo, long a_num,
897  bool a_lock, int a_start,
898  bool a_first_year, TTypesOfVegetation a_crop );
899  bool DoIt(double a_probability);
900  bool DoIt_prob(double a_probability);
901  TTypesOfFarm GetType( void ) { return m_farmtype; }
902  int GetArea(void);
903  int GetTotalArea(void);
904  double GetAreaDouble(void);
905  bool IsStockFarmer( void ) { return m_stockfarmer; }
906  virtual void MakeStockFarmer( void ) { m_stockfarmer = true; }
907  int GetIntensity( void ) { return m_intensity; }
910  int ind = a_index - 1;
911  if (ind < 0) ind = (int)m_rotation.size() - 1;
912  return m_rotation[ind];
913  }
915  return m_rotation[a_index];
916  }
918  int ind = a_index + 1;
919  if (ind >= (int)m_rotation.size()) ind = ind - (int)m_rotation.size();
920  return m_rotation[ind];
921  }
922  void AddHunter(Hunter* a_hunter) {
923  m_HuntersList.push_back( a_hunter );
924  }
925  void RemoveHunter( Hunter* a_hunter ) {
926  for (int h = 0; h < m_HuntersList.size(); h++) {
927  if (m_HuntersList[ h ] == a_hunter) {
928  m_HuntersList.erase( m_HuntersList.begin() + h );
929  }
930  }
931  }
932 
933 protected:
937  vector< LE* > m_fields;
938  vector<TTypesOfVegetation> m_rotation;
939  vector<PermCropData> m_PermCrops;
947  int GetFirstDate( TTypesOfVegetation a_tov );
948  int GetNextCropStartDate( LE* a_field,TTypesOfVegetation &a_curr_veg );
949  virtual int GetFirstCropIndex( TTypesOfLandscapeElement a_type );
950  virtual int GetNextCropIndex( int a_rot_index );
951  virtual void HandleEvents( void );
952  bool LeSwitch( FarmEvent *ev );
954  void ReadRotation(std::string fname);
955 
956  void AssignPermanentCrop(TTypesOfVegetation tov, int pct); //MOVED FROM THE USER DEFINED FARM
957  int InvIntPartition(vector<tpct>* items, int target);
962 
963 
964  // The program function objects for the individual crops.
965  // Remember to add these into the Farm class con- and destructor too.
966  Carrots *m_carrots;
967  BroadBeans *m_broadbeans;
968  FodderGrass *m_foddergrass;
969  CloverGrassGrazed1 *m_CGG1;
970  CloverGrassGrazed2 *m_CGG2;
971  FieldPeas *m_fieldpeas;
972  FieldPeasSilage *m_fieldpeassilage;
973  Fodderbeet *m_fodderbeet;
974  Sugarbeet *m_sugarbeet;
975  OFodderbeet *m_ofodderbeet;
976  Maize *m_maize;
977  MaizeSilage *m_maizesilage;
978  OMaizeSilage *m_omaizesilage;
979  OBarleyPeaCloverGrass *m_OBarleyPCG;
980  OCarrots *m_ocarrots;
981  OCloverGrassGrazed1 *m_OCGG1;
982  OCloverGrassGrazed2 *m_OCGG2;
983  OCloverGrassSilage1 *m_OCGS1;
984  OFieldPeas *m_ofieldpeas;
985  OFieldPeasSilage *m_ofieldpeassilage;
986  OFirstYearDanger *m_ofirstyeardanger;
987  OGrazingPigs *m_ograzingpigs;
988  OrchardCrop *m_orchardcrop;
989  Oats *m_oats;
990  OOats *m_ooats;
991  OPermanentGrassGrazed *m_opermgrassgrazed;
992  OPotatoes *m_opotatoes;
993  OSeedGrass1 *m_oseedgrass1;
994  OSeedGrass2 *m_oseedgrass2;
995  OSpringBarley *m_ospringbarley;
996  OSpringBarleyExt *m_ospringbarleyext;
997  OSpringBarleyPigs *m_ospringbarleypigs;
998  OSBarleySilage *m_osbarleysilage;
999  OTriticale *m_otriticale;
1000  OWinterBarley *m_owinterbarley;
1001  OWinterBarleyExt *m_owinterbarleyext;
1002  OWinterRape *m_owinterrape;
1003  OWinterRye *m_owinterrye;
1004  OWinterWheatUndersown *m_owinterwheatundersown;
1005  OWinterWheat *m_owinterwheat;
1006  OWinterWheatUndersownExt *m_owinterwheatundersownext;
1007  PermanentGrassGrazed *m_permgrassgrazed;
1008  PermanentGrassLowYield *m_permgrasslowyield;
1009  PermanentGrassTussocky *m_permgrasstussocky;
1010  PermanentSetAside *m_permanentsetaside;
1011  Potatoes *m_potatoes;
1012  PotatoesIndustry *m_potatoesindustry;
1013  SeedGrass1 *m_seedgrass1;
1014  SeedGrass2 *m_seedgrass2;
1015  SetAside *m_setaside;
1016  SpringBarley *m_springbarley;
1017  SpringBarleySpr *m_springbarleyspr;
1018  SpringBarleySKManagement *m_springbarleyskmanagement;
1019  SpringBarleyPTreatment *m_springbarleyptreatment;
1020  SpringBarleyCloverGrass *m_sbarleyclovergrass;
1021  SpringBarleySeed *m_springbarleyseed;
1022  SpringBarleySilage *m_springbarleysilage;
1023  SpringRape *m_springrape;
1024  Triticale *m_triticale;
1025  WinterBarley *m_winterbarley;
1026  WinterRape *m_winterrape;
1027  WinterRye *m_winterrye;
1028  WinterWheat *m_winterwheat;
1029  WWheatPControl *m_wwheatpcontrol;
1030  WWheatPToxicControl *m_wwheatptoxiccontrol;
1031  WWheatPTreatment *m_wwheatptreatment;
1032  AgroChemIndustryCereal *m_agrochemindustrycereal;
1033  WinterWheatStrigling *m_winterwheatstrigling;
1034  WinterWheatStriglingCulm *m_winterwheatstriglingculm;
1035  WinterWheatStriglingSingle *m_winterwheatstriglingsingle;
1036  SpringBarleyCloverGrassStrigling *m_springbarleyclovergrassstrigling;
1037  SpringBarleyStrigling *m_springbarleystrigling;
1038  SpringBarleyStriglingCulm *m_springbarleystriglingculm;
1039  SpringBarleyStriglingSingle *m_springbarleystriglingsingle;
1040  MaizeStrigling *m_maizestrigling;
1041  WinterRapeStrigling *m_winterrapestrigling;
1042  WinterRyeStrigling *m_winterryestrigling;
1043  WinterBarleyStrigling *m_winterbarleystrigling;
1044  FieldPeasStrigling *m_fieldpeasstrigling;
1045  SpringBarleyPeaCloverGrassStrigling *m_springbarleypeaclovergrassstrigling;
1046  YoungForestCrop *m_youngforest;
1047  NorwegianPotatoes * m_norwegianpotatoes;
1048  NorwegianOats * m_norwegianoats;
1049  NorwegianSpringBarley* m_norwegianspringbarley;
1050 
1051  PLWinterWheat *m_plwinterwheat;
1052  PLWinterRape *m_plwinterrape;
1053  PLWinterBarley *m_plwinterbarley;
1054  PLWinterTriticale *m_plwintertriticale;
1055  PLWinterRye *m_plwinterrye;
1056  PLSpringWheat *m_plspringwheat;
1057  PLSpringBarley *m_plspringbarley;
1058  PLMaize *m_plmaize;
1059  PLMaizeSilage *m_plmaizesilage;
1060  PLPotatoes *m_plpotatoes;
1061  PLBeet *m_plbeet;
1062  PLFodderLucerne1 *m_plfodderlucerne1;
1063  PLFodderLucerne2 *m_plfodderlucerne2;
1064  PLCarrots *m_plcarrots;
1065  PLSpringBarleySpr *m_plspringbarleyspr;
1066  PLWinterWheatLate *m_plwinterwheatlate;
1067  PLBeetSpr *m_plbeetspr;
1068  PLBeans *m_plbeans;
1069 
1070  NLBeet *m_nlbeet;
1071  NLCarrots *m_nlcarrots;
1072  NLMaize *m_nlmaize;
1073  NLPotatoes *m_nlpotatoes;
1074  NLSpringBarley *m_nlspringbarley;
1075  NLWinterWheat *m_nlwinterwheat;
1076  NLCabbage *m_nlcabbage;
1077  NLTulips *m_nltulips;
1078  NLGrassGrazed1 *m_nlgrassgrazed1;
1079  NLGrassGrazed1Spring *m_nlgrassgrazed1spring;
1080  NLGrassGrazed2 *m_nlgrassgrazed2;
1081  NLGrassGrazedLast *m_nlgrassgrazedlast;
1082  NLPermanentGrassGrazed *m_nlpermanentgrassgrazed;
1083  NLBeetSpring *m_nlbeetspring;
1084  NLCarrotsSpring *m_nlcarrotsspring;
1085  NLMaizeSpring *m_nlmaizespring;
1086  NLPotatoesSpring *m_nlpotatoesspring;
1087  NLSpringBarleySpring *m_nlspringbarleyspring;
1088  NLCabbageSpring *m_nlcabbagespring;
1089  NLCatchPeaCrop *m_nlcatchpeacrop;
1090 
1091  DummyCropPestTesting *m_dummycroppesttesting;
1092  };
1093 
1094 
1098 class ConventionalCattle : public Farm
1099 {
1100 public:
1101  ConventionalCattle( FarmManager* a_manager );
1102 //protected:
1103 // virtual TTypesOfVegetation GetFirstCrop( void );
1104 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1105 };
1106 
1110 class ConventionalPig : public Farm
1111 {
1112 public:
1113  ConventionalPig(FarmManager* a_manager);
1114 //protected:
1115 // virtual TTypesOfVegetation GetFirstCrop( void );
1116 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1117 };
1118 
1122 class ConventionalPlant : public Farm
1123 {
1124 public:
1125  ConventionalPlant(FarmManager* a_manager);
1126  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1127 //protected:
1128 // virtual TTypesOfVegetation GetFirstCrop( void );
1129 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1130 };
1131 
1135 class OrganicPlant : public Farm
1136 {
1137 public:
1138  OrganicPlant(FarmManager* a_manager);
1139  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1140 //protected:
1141 // virtual TTypesOfVegetation GetFirstCrop( void );
1142 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1143 };
1144 
1148 class OrganicPig : public Farm
1149 {
1150 public:
1151  OrganicPig(FarmManager* a_manager);
1152 //protected:
1153 // virtual TTypesOfVegetation GetFirstCrop( void );
1154 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1155 };
1156 
1160 class OrganicCattle : public Farm
1161 {
1162 public:
1163  OrganicCattle(FarmManager* a_manager);
1164 //protected:
1165 // virtual TTypesOfVegetation GetFirstCrop( void );
1166 // virtual TTypesOfVegetation GetNextCrop( TTypesOfVegetation a_veg );
1167 };
1168 
1173 {
1174 public:
1175  PesticideTrialControl(FarmManager* a_manager);
1176  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1177 };
1178 
1183 {
1184 public:
1186  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1187 };
1188 
1193 {
1194 public:
1196  virtual void MakeStockFarmer( void ) { m_stockfarmer = false; }
1197 };
1198 
1199 
1200 
1204 class ConvMarginalJord : public Farm
1205 {
1206 public:
1207  ConvMarginalJord(FarmManager* a_manager);
1208 };
1209 
1210 
1215 {
1216 public:
1218 };
1219 
1224 {
1225 public:
1227 };
1228 
1233 {
1234 public:
1236 };
1237 
1242 {
1243 public:
1244  NoPesticideBaseFarm(FarmManager* a_manager);
1245 };
1246 
1250 class NoPesticideNoPFarm : public Farm
1251 {
1252 public:
1253  NoPesticideNoPFarm(FarmManager* a_manager);
1254 };
1255 
1267 class UserDefinedFarm : public Farm
1268 {
1269 public:
1270  UserDefinedFarm(const char* fname, FarmManager* a_manager);
1271 protected:
1272  virtual void InitiateManagement( void );
1273  //void AssignPermanentCrop(TTypesOfVegetation tov, int pct); //MOVED TO THE FARM CLASS
1274  //int InvIntPartition(vector<tpct>* items, int target);
1275  //void TranslateBitsToFields(int bits, vector<LE*> &f_cpy, TTypesOfVegetation tov);
1276 };
1277 
1278 class UserDefinedFarm1 : public Farm
1279 {
1280 public:
1281  UserDefinedFarm1(FarmManager* a_manager);
1282 };
1283 
1287 class UserDefinedFarm2 : public Farm
1288 {
1289 public:
1290  UserDefinedFarm2(FarmManager* a_manager);
1291 };
1292 
1296 class UserDefinedFarm3 : public Farm
1297 {
1298 public:
1299  UserDefinedFarm3(FarmManager* a_manager);
1300 };
1301 
1305 class UserDefinedFarm4 : public Farm
1306 {
1307 public:
1308  UserDefinedFarm4(FarmManager* a_manager);
1309 };
1310 
1314 class UserDefinedFarm5 : public Farm
1315 {
1316 public:
1317  UserDefinedFarm5(FarmManager* a_manager);
1318 };
1319 
1323 class UserDefinedFarm6 : public Farm
1324 {
1325 public:
1326  UserDefinedFarm6(FarmManager* a_manager);
1327 };
1328 
1332 class UserDefinedFarm7 : public Farm
1333 {
1334 public:
1335  UserDefinedFarm7(FarmManager* a_manager);
1336 };
1337 
1341 class UserDefinedFarm8 : public Farm
1342 {
1343 public:
1344  UserDefinedFarm8(FarmManager* a_manager);
1345 };
1346 
1350 class UserDefinedFarm9 : public Farm
1351 {
1352 public:
1353  UserDefinedFarm9(FarmManager* a_manager);
1354 };
1355 
1359 class UserDefinedFarm10 : public Farm
1360 {
1361 public:
1362  UserDefinedFarm10(FarmManager* a_manager);
1363 };
1364 
1368 class UserDefinedFarm11 : public Farm
1369 {
1370 public:
1371  UserDefinedFarm11(FarmManager* a_manager);
1372 };
1373 
1377 class UserDefinedFarm12 : public Farm
1378 {
1379 public:
1380  UserDefinedFarm12(FarmManager* a_manager);
1381 };
1382 
1386 class UserDefinedFarm13 : public Farm
1387 {
1388 public:
1389  UserDefinedFarm13(FarmManager* a_manager);
1390 };
1391 
1395 class UserDefinedFarm14 : public Farm
1396 {
1397 public:
1398  UserDefinedFarm14(FarmManager* a_manager);
1399 };
1400 
1404 class UserDefinedFarm15 : public Farm
1405 {
1406 public:
1407  UserDefinedFarm15(FarmManager* a_manager);
1408 };
1409 
1413 class UserDefinedFarm16 : public Farm
1414 {
1415 public:
1416  UserDefinedFarm16(FarmManager* a_manager);
1417 };
1418 
1422 class UserDefinedFarm17 : public Farm
1423 {
1424 public:
1425  UserDefinedFarm17(FarmManager* a_manager);
1426 };
1427 
1432 {
1433 public:
1435  UserDefinedFarm18(const char* fname, FarmManager* a_manager);
1436 };
1437 
1442 {
1443 public:
1445  UserDefinedFarm19(const char* fname, FarmManager* a_manager);
1446 };
1447 
1452 {
1453 public:
1455  UserDefinedFarm20(const char* fname, FarmManager* a_manager);
1456 };
1457 
1462 {
1463 public:
1465  UserDefinedFarm21(const char* fname, FarmManager* a_manager);
1466 };
1467 
1472 {
1473 public:
1475  UserDefinedFarm22(const char* fname, FarmManager* a_manager);
1476 };
1477 
1482 {
1483 public:
1485  UserDefinedFarm23(const char* fname, FarmManager* a_manager);
1486 };
1487 
1492 {
1493 public:
1495  UserDefinedFarm24(const char* fname, FarmManager* a_manager);
1496 };
1497 
1502 {
1503 public:
1505  UserDefinedFarm25(const char* fname, FarmManager* a_manager);
1506 };
1507 
1512 {
1513 public:
1515  UserDefinedFarm26(const char* fname, FarmManager* a_manager);
1516 };
1517 
1522 {
1523 public:
1525  UserDefinedFarm27(const char* fname, FarmManager* a_manager);
1526 };
1527 
1532 {
1533 public:
1535  UserDefinedFarm28(const char* fname, FarmManager* a_manager);
1536 };
1537 
1542 {
1543 public:
1545  UserDefinedFarm29(const char* fname, FarmManager* a_manager);
1546 };
1547 
1552 {
1553 public:
1555  UserDefinedFarm30(const char* fname, FarmManager* a_manager);
1556 };
1557 
1562 {
1563 public:
1565  UserDefinedFarm31(const char* fname, FarmManager* a_manager);
1566 };
1567 
1572 {
1573 public:
1575  UserDefinedFarm32(const char* fname,FarmManager* a_manager);
1576 };
1577 
1582 {
1583 public:
1585  UserDefinedFarm33(const char* fname,FarmManager* a_manager);
1586 };
1587 
1592 {
1593 public:
1595  UserDefinedFarm34(const char* fname,FarmManager* a_manager);
1596 };
1597 
1602 {
1603 public:
1605  UserDefinedFarm35(const char* fname,FarmManager* a_manager);
1606 };
1607 
1608 
1609 
1610 //--------------------------------------------------------------------------------------------
1611 //--------------------------OptimisingFarm----------------------------------------------------
1612 //--------------------------------------------------------------------------------------------
1613 
1617 class Livestock {
1618  public:
1620  Livestock(TTypesOfAnimals a_animalType, int a_number);
1628  double m_FUdemand;
1629  };
1630 
1635  public:
1637  CropOptimised(TTypesOfCrops a_cropType, double a_initialArea);
1638  CropOptimised(TTypesOfVegetation a_cropType, double a_initialArea);
1639  CropOptimised(); //another constructor - for the fake crop
1640 
1647 
1648  //parameters: here saved - to make it easier to read them (they are needed very often)
1653 
1654  //optimised variables
1656  double m_n;
1658  double m_nt;
1660  double m_optimalN;
1661 
1663  double m_benefit;
1665  double m_resp;
1667  double m_BIHerb;
1669  double m_BIFi;
1671  double m_BI;
1673  double m_grooming;
1675  double m_hoeing;
1677  double m_weeding;
1679  double m_lossHerb;
1681  double m_lossFi;
1683  double m_totalLoss;
1685  double m_costs_ha;
1687  double m_income_ha;
1689  double m_GM;
1691  double m_savings;
1699  double m_area_ha;
1700 };
1701 
1707 {
1708 public:
1710  FarmManager();
1712  ~FarmManager();
1714  void FarmManagement();
1715  void InitiateManagement( void );
1716  void AddField(int a_OwnerIndex, LE* a_newland, int a_Owner);
1717  void RemoveField(int a_OwnerIndex, LE* a_field);
1718  int ConnectFarm(int a_owner);
1719  TTypesOfVegetation TranslateCropCodes(std::string& str); //moved from farm
1720  void DumpFarmAreas();
1722  void DumpFarmrefs();
1724  void InitFarms();
1728  int GetFarmTotalSize(int a_farmref)
1729  {
1730  return (GetFarmPtr(a_farmref)->GetTotalArea());
1731  }
1733  int GetFarmArableSize(int a_farmref)
1734  {
1735  return (GetFarmPtr(a_farmref)->GetArea());
1736  }
1738  TTypesOfFarm GetFarmType(int a_farmref)
1739  {
1740  return (GetFarmPtr(a_farmref)->GetType());
1741  }
1743  int GetFarmNoFields(int a_farmref)
1744  {
1745  return (GetFarmPtr(a_farmref)->GetNoFields());
1746  }
1749  {
1750  return (GetFarmPtr(a_farmref)->GetValidCoords());
1751  }
1752 
1754  int GetFarmNoOpenFields(int a_farmref, int a_openness)
1755  {
1756  return (GetFarmPtr(a_farmref)->GetNoOpenFields(a_openness));
1757  }
1758 
1760  int GetFarmAreaOpenFields(int a_farmref, int a_openness)
1761  {
1762  return (GetFarmPtr(a_farmref)->GetAreaOpenFields(a_openness));
1763  }
1764 
1766  Farm* GetFarmPtr( int a_owner ) {
1767  for (unsigned int i = 0; i < m_farms.size( ); i++) {
1768  if (a_owner == m_farms[ i ]->GetFarmNumber( )) {
1769  return m_farms[ i ];
1770  }
1771  }
1772  g_msg->Warn( "FarmManager::GetFarmPtr - missing farm ref", a_owner );
1773  exit( 92 );
1774  }
1775 
1777  Farm* GetFarmPtrIndex( int a_index) {
1778  return m_farms[ a_index ];
1779  }
1781  int GetRandomFarmRefnum() { return m_farms[random((int)m_farms.size())]->GetFarmNumber(); }
1783  void CalcCentroids() { for (unsigned int i = 0; i < m_farms.size(); i++) m_farms[i]->Centroids(); }
1785  bool InIllegalList( int a_farm_ref, vector<int> * a_farmlist );
1787  void AddToIllegalList( int a_farm_ref, vector<int> * a_farmlist );
1789  int FindClosestFarm(HunterInfo a_hinfo, vector<int> *a_farmlist);
1791  //int FindClosestFarmProb(HunterInfo a_hinfo, vector<int> *a_farmlist);
1793  int FindClosestFarmOpenness( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness );
1795  int FindClosestFarmOpennessProb( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness );
1797  int FindClosestFarmOpennessProbSmallIsBest( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness, vector<int> * a_farmsizelist );
1799  int FindClosestFarmOpennessProbNearRoostIsBest( HunterInfo a_hinfo, vector<int> * a_farmlist, int a_openness, vector<APoint> * a_farmsizelist );
1801  int FindFarmWithRandom(vector<int> * a_farmlist);
1803  int FindFarmWithOpenness(vector<int> * a_farmlist, int a_openness);
1805  int FindOpennessFarm(int a_openness);
1807  bool CheckOpenness( int a_openness, int a_ref );
1809  APoint GetFarmCentroid(int a_farmref)
1810  {
1811  for (unsigned int i = 0; i < m_farms.size(); i++)
1812  {
1813  if (a_farmref == m_farms[i]->GetFarmNumber())
1814  {
1815  return m_farms[i]->GetCentroids();
1816  }
1817  }
1818  g_msg->Warn("FarmManager::GetFarmCentroid - missing farm ref", a_farmref);
1819  exit(92);
1820  }
1822  bool IsDuplicateRef(int a_ref, HunterInfo* a_hinfo);
1824  double GetSpilledGrain();
1826  double GetSpilledMaize();
1828  void SetSpilledGrain( bool a_spilledgrain ) {
1829  m_SpilledGrain = a_spilledgrain;
1830  }
1831 //for the decision making
1833  void FindNeighbours();
1835  double GetDD (void){return daydegrees;};
1836  void SetDD (double a_dd){daydegrees = a_dd;};
1837  double Get_cropTotals (int i) {return m_cropTotals[i];};
1838  void Add_to_cropTotals (int i, double value){m_cropTotals[i] += value;};
1839  void Set_cropTotals (int i, double value){m_cropTotals[i] = value;};
1840  int Get_cropTotals_size (){return (int)m_cropTotals.size();};
1842  void ActualProfit();
1848  void PrintDecModes_counts();
1850  void PrintFinalResults();
1852  void Switch_rotation();
1854  void Set_crops_summary_BIs_herb(int i, double BIherb){m_crops_summary_BIs[i].BIherb += BIherb;};
1855  void Set_crops_summary_BIs_fi(int i, double BIfi){m_crops_summary_BIs[i].BIfi += BIfi;};
1856  void Set_crops_summary_BIs (int i, double BI){m_crops_summary_BIs[i].BI += BI;};
1857  void Set_cropTotals_sum(int i, double crop_area){m_cropTotals_sum[i] += crop_area;};
1858  void Set_cropTotals_plant_sum(int i, double crop_area){m_cropTotals_plant_sum[i] += crop_area;};
1859  void Set_cropTotals_pig_sum(int i, double crop_area){m_cropTotals_pig_sum[i] += crop_area;};
1860  void Set_cropTotals_cattle_sum(int i, double crop_area){m_cropTotals_cattle_sum[i] += crop_area;};
1861  void Set_cropTotals_other_sum(int i, double crop_area){m_cropTotals_other_sum[i] += crop_area;};
1862 
1863  void Set_crops_fertilizer (int i, double fert){m_crops_fertilizer[i] += fert;};
1864  void Set_crops_fertilizer_trade (int i, double fert_trade){m_crops_fertilizer_trade[i] += fert_trade;};
1865 
1866 
1867  TTypesOfOptFarms TranslateFarmCodes(string &str);
1868  TTypesOfSoils TranslateSoilCodes(string &str);
1870  TTypesOfAnimals TranslateAnimalsCodes (string &str);
1871  TTypesOfCrops TranslateCropsCodes (string &str);
1877  ofstream * pm_output_file;
1878 
1879  int Get_lookup_table(int index){return m_crop_lookup_table[index];};
1880 
1882  int GetFarmNoLookup(int a_ref) { return m_farmmapping_lookup[a_ref * 2]; }
1884  int GetFarmTypeLookup(int a_ref) { return m_farmmapping_lookup[a_ref * 2 + 1]; }
1886  bool GetIsRenumbered() { return m_renumbered; }
1888  int GetRenumberedFarmRef(int a_farmref)
1889  {
1890  for (int i = 0; i < (int)m_farms.size(); i++)
1891  {
1892  if (m_farmmapping_lookup[i * 2] == a_farmref)
1893  {
1894  return i;
1895  }
1896  }
1897  g_msg->Warn( "FarmManager::GetRenumberedFarmRef(int a_farmref) Farm reference number not found in m_farmmapping_lookup ", a_farmref );
1898  exit( 9 );
1899  }
1900  int GetNoFarms( ) {
1901  return (int)m_farms.size();
1902  }
1903 
1904 
1905 protected:
1906  vector<Farm*> m_farms;
1908  void CreateFarms( const char *a_farmfile );
1910  double daydegrees;
1913 
1918 
1919 
1920 //for the optimisation
1921 
1925  double BIherb;
1926  double BIfi;
1927  double BI;
1928  };
1929 
1935 
1937  vector<double>m_cropTotals;
1941  vector<double>m_cropTotals_sum;
1943  vector<double>m_cropTotals_plant_sum;
1945  vector<double>m_cropTotals_pig_sum;
1949  vector<double>m_cropTotals_other_sum;
1951  vector<PesticideData>m_crops_summary_BIs;
1953  vector<double>m_crops_fertilizer;
1957  vector<double>m_crop_areas_stages;
1958 
1959 
1960  //data at a farm level
1962  void ReadFarmsData();
1964  void ReadLivestockNumbers();
1966  void ReadInitialCropAreas();
1967 
1968  //data for farms
1971 
1972  //data for livestock
1974  void ReadLivestockData();
1975 
1976  //data for crops
1978  void ReadCropsData();
1987 
1988  //data for almass crops:
1992  void ReadCropsData_almass();
2001 
2002  //for energy maize runs
2003  void ReadEnergyMaizePrice();
2004 
2005  //methods
2006 
2008  void OptimisationOutput();
2010  void PrintOutput(TTypesOfCropVariables a_var, string a_fileName);
2012  void CropDistribution();
2016  void ReadLookupTable();
2018  void PrintNeighbours();
2020  void DistributeFarmerTypes();
2021 
2022 };
2023 
2024 
2028 class OptimisingFarm : public Farm
2029 {
2030 public:
2032  OptimisingFarm( FarmManager* a_myfarmmanager, int a_No);
2033  virtual ~OptimisingFarm() { ; }
2037  int Get_farmRealID (void) {return m_farmRealID;}
2038  int Get_soilSubType (void) {return m_soilSubType;}
2039  int Get_almass_no (void) {return m_almass_no;}
2040  CropOptimised* Get_crop (int i) {return m_crops[i];}
2041  int Get_cropsSize(void) {return (int)m_crops.size();}
2042  void Set_Livestock (Livestock* p_lvs){m_livestock.push_back(p_lvs);};
2043  void Set_Crop(CropOptimised* p_crop){m_crops.push_back(p_crop);};
2044 
2045  //-------------------------------------------------------------------------------------------------------------
2046  //for the modified dec. making - using CONSUMAT approach
2047 
2048  void Set_Neighbour(OptimisingFarm* farm){m_neighbours.push_back(farm);};
2049  int Get_NeighboursSize(void) {return (int)m_neighbours.size();};
2051  vector<AlmassCrop> Get_rotational_crops(){return m_rotational_crops;};
2057  void Set_main_goal (TTypeOfFarmerGoal a_goal){m_main_goal = a_goal;};
2059  void Set_animals_no (int a_number){animals_no = a_number;};
2060  int Get_decision_mode_counters (int index){return m_decision_mode_counters[index];};
2062  bool Harvest( LE *a_field, double a_user, int a_days );
2064  void Match_crop_to_field(LE* a_field);
2067 
2069  void ActualProfit();
2071  void Save_last_years_crops();
2073  void ChooseDecisionMode();
2075  virtual bool Spraying_herbicides(TTypesOfVegetation a_tov_type);
2077  virtual bool Spraying_fungins(TTypesOfVegetation a_tov_type);
2079  virtual double Prob_multiplier ();
2080 
2081  //-------------------------------------------------------------------------------------------------------------
2082 
2084  void Init(ofstream * ap_output_file);
2085 
2086 protected:
2088  virtual void InitiateManagement( void );
2090  void Initialize(FarmManager * a_pfm);
2091  virtual void HandleEvents( void );
2093  virtual bool FungicideTreat( LE *a_field, double /*a_user*/, int a_days );
2095  virtual bool InsecticideTreat( LE *a_field, double /*a_user*/, int a_days );
2097  virtual bool HerbicideTreat( LE *a_field, double /*a_user*/, int a_days );
2098 
2099  //----------------------------------------------------------------------------------------------------
2100  //'farmer' variables - for the modified decision making
2101 
2104  //TTypeOfFarmerGoal m_pest_goal;
2105  //TTypeOfFarmerGoal m_fert_goal;
2106 
2108  vector<OptimisingFarm*>m_neighbours;
2115 
2116  //the actual and expected values
2128  double m_exp_costs;
2135 
2137  vector<double>m_previous_profits;
2139  vector<double>m_previous_incomes;
2141  vector<double>m_previous_costs;
2148 
2150  vector<double>m_animals_numbers;
2155 
2156  //-----------------------------------------------------------------------------------------------------
2157 
2158 
2159  //structs
2161  struct CropSort {
2162  double key;
2164  };
2165 
2167  struct reverseSort {
2168  bool operator()(CropSort a, CropSort b) { return a.key > b.key; }
2169  };
2170 
2173  struct MakeRotation {
2174  bool taken;
2176  };
2177 
2178 
2179  //lists - vectors
2181  vector<Livestock*>m_livestock;
2183  vector<CropOptimised*>m_crops;
2185  vector<CropSort>m_variableCrops;
2190  vector<CropSort>m_variableCrops2;
2192  vector<CropOptimised*>m_grownVariableCrops;
2194  vector<CropOptimised*>m_fixedCrops;
2196  vector<CropSort>m_rotationCrops;
2198  vector<CropSort>m_winterCrops;
2200  vector<AlmassCrop>m_crops_almass;
2202  vector<AlmassCrop>m_rotational_crops;
2204  vector<AlmassCrop>m_rotational_crops_copy;
2206  vector<AlmassCrop>m_rotational_crops_visible;
2207 
2208  //farm parameters (not-farm specific parameters are stored in the DataForOptimisation class)
2221 
2222  //variables
2224  double m_totalArea;
2232  double m_Nanim;
2238  double m_totalFUt;
2242  double m_assigned;
2244  double m_totalN;
2246  double m_totalNt;
2250  double m_totalBIFi;
2252  double m_totalBI;
2266  double m_area_rot;
2267 
2268 
2269  // methods
2270 
2272  virtual void createCropsLists(int a_foobar);
2274  void createVariableCrops(int a_foobar);
2276  void FarmLevelCalculation();
2278  void OptimiseFarm(int a_foobar);
2279 
2281  void Check_SG_and_CGG();
2282 
2283  //METHODS FOR FARM VARIABLES
2285  void findTotalArea();
2287  void findTotalNanim();
2289  void findNanim();
2291  virtual void findFodderDemand();
2293  virtual void preventCashCrops(){};
2294 
2295 
2296  //OPTIMISATION
2298  void optimizeCrops(int a_foobar);
2299 
2300  //OPTIMISATION - SIMPLIFIED METHOD
2302  void findFertilizer(CropOptimised * a_crop, int a_foobar, double benefit);
2304  void findResponse(CropOptimised * a_crop, int a_foobar);
2306  void findBIs(CropOptimised * a_crop, double benefit);
2308  void fixBI();
2310  void findMWeedControl(CropOptimised * a_crop);
2312  void findYieldLoss(CropOptimised * a_crop);
2314  void findGrossMargin(CropOptimised * a_crop, int a_foobar, double benefit);
2315 
2316  //AREA ASSIGNMENT
2318  void assignFixed();
2320  void sumMinAreas();
2322  virtual void determineAreas(int a_foobar);
2324  void determineAreas_ha(vector<CropOptimised*>crops);
2325 
2326  //RESTRICTIONS - CROPS AREA
2328  virtual void checkRestrictions();
2330  virtual void checkWinterRotation1(){};
2332  virtual void checkWinterCrops(){};
2335 
2336  //OTHER FUNCTIONS
2338  double crop_parameter(int index, string par_name);
2340  CropOptimised * findCropByName (string crop_name);
2342  CropOptimised * findCropByName_almass (string crop_name);
2346  double total(TTypesOfCropVariables variable_name);
2348  void sortCrops(vector<CropSort> &cropsToSort, string sortingKey);
2350  void randomizeCropList(vector<CropSort> &listToRandomize, string key);
2352  virtual void increaseCrops(vector<CropSort>cropsToIncrease, double &howMuchToIncrease);
2354  virtual void decreaseCrops(vector<CropSort>cropsToDecrease, double &howMuchToDecrease);
2356  void Print_FarmVariables (ofstream * ap_output_file);
2358  void Make_rotations();
2360  void Check_if_area_100();
2364  void Make_almass_crops_vector();
2366  void Make_rotational_crops();
2368  void Print_rotations(ofstream * ap_output_file);
2369 
2370 };
2371 
2376 public:
2377  AnimalFarm(FarmManager * a_myfarmmanager, int a_No);
2378  virtual ~AnimalFarm(){};
2379 protected:
2380 
2386  vector<CropSort>m_fodderCrops;
2387 
2388  //variables
2389 
2398 
2399  //methods
2400  virtual void createCropsLists(int a_foobar);
2402  virtual void determineAreas(int a_foobar);
2403 
2404  //FODDER CROPS
2406  void createFodderCrops(int a_foobar);
2410  void correctFodderDemand(int a_foobar);
2412  void determineFodderAreas(int a_foobar);
2414  void determineMinFodder(int a_foobar);
2415 
2416  //RESTRICTIONS - CROPS AREA
2418  virtual void checkWinterRotation1();
2420  virtual void checkWinterCrops();
2421 
2422  //OTHER
2424  virtual void increaseCrops(vector<CropSort>cropsToIncrease, double &howMuchToIncrease);
2426  virtual void decreaseCrops(vector<CropSort>cropsToDecrease, double &howMuchToDecrease);
2427 
2428 };
2429 
2434 public:
2435  OptimisingPigFarm(FarmManager* a_myfarmmanager, int a_No);
2436  virtual ~OptimisingPigFarm(){};
2437 
2438 protected:
2440  virtual void checkRestrictions();
2442  void check_WRape_WBarley();
2443 };
2444 
2449 public:
2450  OptimisingCattleFarm(FarmManager* a_myfarmmanager, int a_No);
2452 
2453 protected:
2455  vector<CropSort>m_cattleCrops;
2457  vector<CropSort>m_cattleCrops_almass;
2459  virtual void checkRestrictions();
2461  void checkCattleRotation();
2465  void setCattleCropsAtMin();
2467  virtual void preventCashCrops();
2468 
2469 };
2470 
2471 
2476 public:
2477  NonAnimalFarm(FarmManager * a_myfarmmanager, int a_No);
2478  virtual ~NonAnimalFarm(){};
2479 protected:
2480 
2481  //methods
2482  //METHODS FOR FARM VARIABLES
2483  virtual void findFodderDemand();
2484 
2485  //RESTRICTIONS
2487  virtual void checkWinterRotation1();
2489  virtual void checkWinterCrops();
2490 };
2491 
2496 public:
2497  OptimisingPlantFarm(FarmManager* a_myfarmmanager, int a_No);
2499 };
2500 
2505 public:
2506  OptimisingOtherFarm(FarmManager* a_myfarmmanager, int a_No);
2508 };
2509 
2510 
2511 
2512 
2513 
2514 #endif // FARM_H
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
int m_y
Definition: ALMaSS_Setup.h:56
int m_x
Definition: ALMaSS_Setup.h:55
Inbuilt special purpose farm type.
Definition: farm.h:1215
AgroChemIndustryCerealFarm1(FarmManager *a_manager)
Definition: farm.cpp:2097
Inbuilt special purpose farm type.
Definition: farm.h:1224
AgroChemIndustryCerealFarm2(FarmManager *a_manager)
Definition: farm.cpp:2114
Inbuilt special purpose farm type.
Definition: farm.h:1233
AgroChemIndustryCerealFarm3(FarmManager *a_manager)
Definition: farm.cpp:2130
Subclass of the OptimisingFarm. Either pig or cattle farm.
Definition: farm.h:2375
virtual void checkWinterRotation1()
Animal farm version of the OptimisingFarm::checkWinterRotation1() function (accounts for fodder chang...
Definition: farm.cpp:6636
double m_fodderToProduceBefore
Fodder that has to be produced to fulfill the min. fodder production restriction at the beginning of ...
Definition: farm.h:2395
virtual void decreaseCrops(vector< CropSort >cropsToDecrease, double &howMuchToDecrease)
Decreases area of cropsToDecrease by howMuchToDecrease.
Definition: farm.cpp:7931
double m_totalFodderToProduce
Fodder that has to be produced by a farm to fulfill the min. fodder production restriction....
Definition: farm.h:2391
void determineMinFodder(int a_foobar)
Covers the min. required fodder production for animal farms.
Definition: farm.cpp:7541
void createFodderCrops(int a_foobar)
Creates a list of pointers to all fodder crops.
Definition: farm.cpp:5596
void correctFodderDemand(int a_foobar)
Determines how much fodder is produced from fixed crops and min. areas of variable crops.
Definition: farm.cpp:7488
virtual void increaseCrops(vector< CropSort >cropsToIncrease, double &howMuchToIncrease)
Increases area of cropsToIncrease by howMuchToIncrease.
Definition: farm.cpp:7874
bool cash_crops_allowed
Sets to true if cash crops are allowed. True by default.
Definition: farm.h:2397
void determineFodderAreas(int a_foobar)
Determines areas of fodder crops and corrects areas of non-fodder crops.
Definition: farm.cpp:7619
bool m_fakeCropTest
Set to true if the fake crop is present after determineAreas function.
Definition: farm.h:2384
CropOptimised * m_fakeCrop
Crop used to fill up area of a farm up to 100% in case its non-fodder crops do not sum to 100% in det...
Definition: farm.h:2378
void findFodderCropSavings()
Determines the savings resulting from growing a fodder crop relative to purchasing fodder.
virtual ~AnimalFarm()
Definition: farm.h:2378
vector< CropSort > m_fodderCrops
List of pointers to variable (non-fixed) fodder crops.
Definition: farm.h:2386
virtual void createCropsLists(int a_foobar)
Creates lists of crops.
Definition: farm.cpp:5574
AnimalFarm(FarmManager *a_myfarmmanager, int a_No)
Definition: farm.cpp:5270
virtual void checkWinterCrops()
Animal farm version of the checkWinterCrops() function (accounts for fodder changes).
Definition: farm.cpp:6932
virtual void determineAreas(int a_foobar)
Determines areas of variable crops.
Definition: farm.cpp:6373
double m_fodderToProduce
Fodder that has to be produced to fulfill the min. fodder production restriction at the end of a year...
Definition: farm.h:2393
Inbuilt special purpose farm type.
Definition: farm.h:1205
ConvMarginalJord(FarmManager *a_manager)
Definition: farm.cpp:2083
Inbuilt farm type.
Definition: farm.h:1099
ConventionalCattle(FarmManager *a_manager)
Definition: farm.cpp:1982
Inbuilt farm type.
Definition: farm.h:1111
ConventionalPig(FarmManager *a_manager)
Definition: farm.cpp:2000
Inbuilt farm type.
Definition: farm.h:1123
virtual void MakeStockFarmer(void)
Definition: farm.h:1126
ConventionalPlant(FarmManager *a_manager)
Definition: farm.cpp:2019
The base class for all crops.
Definition: farm.h:535
int m_first_date
Definition: farm.h:540
int m_ddegstoharvest
Definition: farm.h:543
int m_last_date
Definition: farm.h:542
FarmEvent * m_ev
Definition: farm.h:539
int GetFirstDate(void)
Definition: farm.h:562
int GetCropClassification()
Definition: farm.h:567
virtual ~Crop()
Definition: farm.h:560
Crop()
Definition: farm.cpp:297
Farm * m_farm
Definition: farm.h:537
void SetCropClassification(int a_classification)
Definition: farm.h:569
LE * m_field
Definition: farm.h:538
int m_count
Definition: farm.h:541
void SimpleEvent_(long a_date, int a_todo, bool a_lock, Farm *a_farm, LE *a_field)
Adds an event to this crop management without relying on member variables.
Definition: farm.cpp:312
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: farm.cpp:307
int m_CropClassification
Definition: farm.h:545
virtual bool Do(Farm *a_farm, LE *a_field, FarmEvent *a_ev)
Definition: farm.cpp:303
void ChooseNextCrop(int a_no_dates)
Chooses the next crop to grow in a field.
Definition: farm.cpp:318
A class for storing all parameters and results of crop optimisation.
Definition: farm.h:1634
double m_grooming
Value of mechanical weed control for a crop - grooming [DKK/ha].
Definition: farm.h:1673
double m_GM
Value of gross margin for a crop (m_income_ha - m_costs_ha) [DKK/ha].
Definition: farm.h:1689
double m_rotationMin
Minimum area in percent of farm's arable area for a given crop (depends on a farm size,...
Definition: farm.h:1652
double m_initialArea
Initial area of a crop on a farm [ha].
Definition: farm.h:1642
double m_optimalN
Optimal amount of fertilizer per ha of a crop supposing ferilizer price equals zero [kg N/ha]....
Definition: farm.h:1660
double m_areaVariable
Area of a crop that can be changed when checking for restrictions (=m_areaPercent - m_rotationMin) [%...
Definition: farm.h:1697
double m_savings
Value of savings resulting from growing a fodder crop and not purchasing amount of fodder correspondi...
Definition: farm.h:1691
double m_hoeing
Value of mechanical weed control for a crop - hoeing [DKK/ha].
Definition: farm.h:1675
double m_benefit
A value of selling price for non-fodder crops or a value of fodder units obtained from a hkg of a fod...
Definition: farm.h:1663
double m_n
Total amount of fertilizer applied per ha of a crop [kg N/ha].
Definition: farm.h:1656
double m_area_ha
Area of a crop in ha at a farm [ha].
Definition: farm.h:1699
double m_BIFi
Value of BI for fung- and insecticides [BI/ha].
Definition: farm.h:1669
double m_BIHerb
Value of BI for herbicides [BI/ha].
Definition: farm.h:1667
double m_lossHerb
Value of the yield loss due to the limited use of herbicides [%].
Definition: farm.h:1679
double m_nt
Amount of purchased (and applied) fertilizer per ha of a crop [kg N/ha].
Definition: farm.h:1658
double m_lossFi
Value of the yield loss due to the limited use of fung- and insecticides [%].
Definition: farm.h:1681
double m_rotationMax
Maximum area in percent of farm's arable area for a given crop (depends on a farm size,...
Definition: farm.h:1650
double m_totalLoss
Summary value of the yield loss due to the limited use of herbicides and fung- and insecticides [%].
Definition: farm.h:1683
TTypesOfVegetation m_cropType_almass
Type/name of a crop (ALMaSS crops).
Definition: farm.h:1646
double m_areaPercent
Area of a crop in percent of a farm's total area [%].
Definition: farm.h:1695
double m_resp
Response - yield of a crop per ha [hkg/ha].
Definition: farm.h:1665
double m_GM_Savings
Holds the value of m_GM in case of non-fodder crops and a value of m_savings in case of fodder crops ...
Definition: farm.h:1693
TTypesOfCrops m_cropType
Type/name of a crop (original farm optimization model crop types).
Definition: farm.h:1644
double m_BI
Summary value of BI for herbicides and fung- and insecticides [BI/ha].
Definition: farm.h:1671
CropOptimised()
Definition: farm.cpp:5118
double m_income_ha
Value of income per ha of a crop. Includes value of sales and subsidy [DKK/ha].
Definition: farm.h:1687
double m_weeding
Value of mechanical weed control for a crop - manual weeding [DKK/ha].
Definition: farm.h:1677
double m_costs_ha
Costs of growing 1 ha of a crop. Include costs of labour and machine (constant), pesticides (herbicid...
Definition: farm.h:1685
Class storing farm information: farm's number used in ALMaSS system, farm's soil type,...
Definition: farm.h:675
int md_farmRealID
Definition: farm.h:681
int md_almass_no
Definition: farm.h:677
int md_soilSubType
Definition: farm.h:682
TTypesOfFarmSize md_farmSize
Definition: farm.h:680
TTypesOfOptFarms md_farmType
Definition: farm.h:678
TTypesOfSoils md_soilType
Definition: farm.h:679
Class for storing data for optimisation.
Definition: farm.h:589
vector< int > m_winterMax
Maximal area taken by winter crops at a farm. [%].
Definition: farm.h:716
void Set_fixed(string a_value, int i)
Definition: farm.h:634
int Get_noCrops()
Definition: farm.h:669
void Set_FUKey(double a_value, int i)
Definition: farm.h:644
int Get_cropAreasSize()
Definition: farm.h:608
void Set_noCrops(int no)
Definition: farm.h:668
void Set_cropArea(double a_area)
Definition: farm.h:604
DataForOptimisation()
The constructor.
Definition: farm.cpp:5050
vector< double > m_rotationMin
Minimum acreage of a crop at a farm [%]. Farm type, soil type and farm size specific.
Definition: farm.h:755
double Get_beta2(int i)
Definition: farm.h:629
void Set_sellingPrice(double a_value, int i)
Definition: farm.h:647
void Set_livestockParameter(double a_value, int i)
Definition: farm.h:617
vector< TTypesOfAnimals > m_livestockTypes
Livestock types saved as enumarator types.
Definition: farm.h:709
int Get_cropTypes_almass_size()
Definition: farm.h:664
vector< double > m_energy_maize_price
Vector with energy maize prices for each year of simulation.
Definition: farm.h:759
vector< bool > m_fixed
Crop Boolean parameter - fixed/variable crop. Farm type specific.
Definition: farm.h:741
vector< string > m_str_cropTypes
Crop types saved in string format (Bedriftsmodel i.e. original crop optimization model crop mode).
Definition: farm.h:700
TTypesOfVegetation Get_cropTypes_almass(int i)
Definition: farm.h:663
void InitializeVector(vector< double > &vector)
Initializes vector with -1 values.
Definition: farm.cpp:5039
int Get_winterMax(int i)
Definition: farm.h:614
void Set_biomass_factor(double a_value, int i)
Definition: farm.h:659
int Get_livestockNumber(int index)
Definition: farm.h:605
void Set_rotationMax(double a_value, int i)
Definition: farm.h:652
double Get_biomass_factor(int i)
Definition: farm.h:660
void Set_beta1(double a_value, int i)
Definition: farm.h:626
int Get_livestockNumbersSize()
Definition: farm.h:606
double Get_rotationMin(int i)
Definition: farm.h:655
vector< double > m_livestockParameters
Vector storing parameters of all livestock types.
Definition: farm.h:720
vector< double > m_FUKey
Crop parameter: Fodder unit key, i.e. a number of fodder units obtained from a given crop [FU/hkg]....
Definition: farm.h:745
void Set_rotationMin(double a_value, int i)
Definition: farm.h:654
string Get_cropTypes_almass_str(int i)
Definition: farm.h:666
double Get_sellingPrice(int i)
Definition: farm.h:648
void Set_emaize_price(double a_value)
Definition: farm.h:671
string Get_cropTypes_str(int i)
Definition: farm.h:599
void Set_alfa(double a_value, int i)
Definition: farm.h:624
vector< TTypesOfCrops > m_cropTypes
Crop types saved as enumarator types (Bedriftsmodel i.e. original crop optimization model crop mode).
Definition: farm.h:702
vector< double > m_cropAreas
Vector containing values of initial (i.e. in year the data is taken for) crop areas at farms included...
Definition: farm.h:711
double Get_livestockParameter(int i)
Definition: farm.h:618
void Set_fodder(string a_value, int i)
Definition: farm.h:639
vector< double > m_beta1
Crop parameter for response (growth) function (resp = alfa + beta1*N + beta2*N^2; defines relationshi...
Definition: farm.h:730
bool Get_fodder(int i)
Definition: farm.h:643
TTypesOfAnimals Get_livestockTypes(int i)
Definition: farm.h:598
vector< double > m_sellingPrice_lastyr
Selling price of a crop in a previous year [DKK/hkg]. Farm type specific and soil type specific.
Definition: farm.h:750
TTypesOfCrops Get_cropTypes(int i)
Definition: farm.h:600
double Get_alfa(int i)
Definition: farm.h:625
vector< double > m_Nnorm
Maximum amount of fertilizer (N) that can be applied for a given crop [kg N/ha]. Soil specific.
Definition: farm.h:734
TTypesOfOptFarms Get_farmType(int a_almass_no)
Used by FarmManager::CreateFarms. Finds a matching almass number and returns farm's type.
Definition: farm.cpp:5086
vector< double > m_biomass_factors
Factor used to determine actual response (yield per ha) based on crop biomass at a harvest....
Definition: farm.h:737
double Get_rotationMax(int i)
Definition: farm.h:653
vector< bool > m_fodder
Crop Boolean parameter - fodder/non-fodder crop. Farm type specific.
Definition: farm.h:743
double Get_Nnorm(int i)
Definition: farm.h:631
void Set_cropTypes_almass(TTypesOfVegetation crop_type)
Definition: farm.h:662
int m_noCrops
Number of crops used in the simulation.
Definition: farm.h:693
double Get_FUKey(int i)
Definition: farm.h:645
void Set_cropTypes_str(string crop_type)
Definition: farm.h:597
void Set_sellingPrice_lastyr(double a_value, int i)
Definition: farm.h:649
void Set_Nnorm(double a_value, int i)
Definition: farm.h:630
void Set_cropTypes(TTypesOfCrops crop_type)
Definition: farm.h:596
bool Get_fixed(int i)
Definition: farm.h:638
vector< TTypesOfVegetation > m_cropTypes_almass
Crop types saved as enumarator types (ALMaSS crop mode).
Definition: farm.h:707
void Set_cropParameter(double a_value, int i)
Definition: farm.h:621
vector< double > m_sellingPrice
Selling price of a crop [DKK/hkg]. Farm type specific and soil type specific.
Definition: farm.h:748
vector< double > m_beta2
Crop parameter for response (growth) function (resp = alfa + beta1*N + beta2*N^2; defines relationshi...
Definition: farm.h:732
double Get_cropParameter(int i)
Definition: farm.h:622
vector< int > m_livestockNumbers
Vector containing numbers of all livestock types at farms included in the simulation.
Definition: farm.h:713
void Set_cropTypes_almass_str(string crop_type)
Definition: farm.h:665
void Set_beta2(double a_value, int i)
Definition: farm.h:628
double Get_beta1(int i)
Definition: farm.h:627
void Set_winterMax(int a_value, int i)
Definition: farm.h:613
vector< double > m_alfa
Crop parameter for response (growth) function (resp = alfa + beta1*N + beta2*N^2; defines relationshi...
Definition: farm.h:728
void Set_livestockTypes(TTypesOfAnimals livestock_type)
Definition: farm.h:595
double Get_cropArea(int index)
Definition: farm.h:607
vector< FarmData * > m_farm_data
Definition: farm.h:685
void Set_livestockNumber(int a_number)
Definition: farm.h:603
vector< string > m_str_cropTypes_almass
Crop types saved in string format (ALMaSS crop mode).
Definition: farm.h:705
vector< double > m_rotationMax
Maximum acreage of a crop at a farm [%]. Farm type, soil type and farm size specific.
Definition: farm.h:753
double Get_emaize_price(int i)
Definition: farm.h:672
vector< double > m_cropParameters
Vector storing parameters of all crop types.
Definition: farm.h:725
double Get_sellingPrice_lastyr(int i)
Definition: farm.h:650
The base class for all farm types.
Definition: farm.h:768
NLMaize * m_nlmaize
Definition: farm.h:1072
void ReadRotation(std::string fname)
Reads a rotation file into the rotation.
Definition: farm.cpp:816
OPotatoes * m_opotatoes
Definition: farm.h:992
Potatoes * m_potatoes
Definition: farm.h:1011
virtual bool CattleOutLowGrazing(LE *a_field, double a_user, int a_days)
Start a extensive grazing event on a_field today.
Definition: farmfuncs.cpp:1944
virtual bool Spraying_fungins(TTypesOfVegetation)
Definition: farm.h:785
virtual bool FA_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:917
WinterRapeStrigling * m_winterrapestrigling
Definition: farm.h:1041
virtual bool CutToSilage(LE *a_field, double a_user, int a_days)
Cut vegetation for silage on a_field.
Definition: farmfuncs.cpp:2329
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: farm.cpp:800
virtual bool FA_Slurry(LE *a_field, double a_user, int a_days)
Spready slurry on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:965
OWinterWheatUndersownExt * m_owinterwheatundersownext
Definition: farm.h:1006
SeedGrass2 * m_seedgrass2
Definition: farm.h:1014
virtual bool HayTurning(LE *a_field, double a_user, int a_days)
Carry out hay turning on a_field.
Definition: farmfuncs.cpp:2159
virtual void MakeStockFarmer(void)
Definition: farm.h:906
int GetFarmNumber(void)
Definition: farm.h:782
virtual bool ShallowHarrow(LE *a_field, double a_user, int a_days)
Carry out a shallow harrow event on a_field, e.g., after grass cutting event.
Definition: farmfuncs.cpp:498
virtual void InitiateManagement(void)
Kicks off the farm's management.
Definition: farm.cpp:1514
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
Definition: farm.h:1035
virtual bool FP_LiquidNH3(LE *a_field, double a_user, int a_days)
Apply liquid ammonia fertilizer to a_field owned by an arable farmer.
Definition: farmfuncs.cpp:677
int GetAreaOpenFields(int a_openness)
Returns the area of the fields above an openness of a_openness.
Definition: farm.cpp:1369
polylist * ListOpenFields(int a_openness)
Returns a list of fields with openness above a_openness.
Definition: farm.cpp:9399
PLMaize * m_plmaize
Definition: farm.h:1058
OSeedGrass2 * m_oseedgrass2
Definition: farm.h:994
vector< PermCropData > m_PermCrops
Definition: farm.h:939
virtual bool FP_GreenManure(LE *a_field, double a_user, int a_days)
Spread green manure on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:798
MaizeSilage * m_maizesilage
Definition: farm.h:977
OCarrots * m_ocarrots
Definition: farm.h:980
void RemoveHunter(Hunter *a_hunter)
Definition: farm.h:925
int m_intensity
Definition: farm.h:946
virtual bool HayBailing(LE *a_field, double a_user, int a_days)
Carry out hay bailing on a_field.
Definition: farmfuncs.cpp:2184
void AddField(LE *a_newfield)
Adds a field to a farm.
Definition: farm.cpp:1447
OWinterRye * m_owinterrye
Definition: farm.h:1003
virtual bool StriglingSow(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding followed by sowing on a_field.
Definition: farmfuncs.cpp:1597
void Centroids()
Finds farm's centroids - x and y.
Definition: farm.cpp:5334
bool LeSwitch(FarmEvent *ev)
Call do function for any crop with an outstanding event. Signal if the crop has terminated.
Definition: farm.cpp:386
PLMaizeSilage * m_plmaizesilage
Definition: farm.h:1059
WinterRape * m_winterrape
Definition: farm.h:1026
virtual bool PigsAreOut(LE *a_field, double a_user, int a_days)
Start a pig grazing event on a_field today or soon.
Definition: farmfuncs.cpp:2112
virtual bool SpringPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the spring on a_field.
Definition: farmfuncs.cpp:444
NLBeetSpring * m_nlbeetspring
Definition: farm.h:1083
virtual bool CattleOut(LE *a_field, double a_user, int a_days)
Start a grazing event on a_field today.
Definition: farmfuncs.cpp:1910
virtual bool FP_PK(LE *a_field, double a_user, int a_days)
Apply PK fertilizer, on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:653
int GetFirstDate(TTypesOfVegetation a_tov)
Gets the start date for a crop type.
Definition: farm.cpp:1582
virtual bool RowCultivation(LE *a_field, double a_user, int a_days)
Carry out a harrowing between crop rows on a_field.
Definition: farmfuncs.cpp:1510
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
Definition: farm.h:1045
virtual bool FA_RSM(LE *a_field, double a_user, int a_days)
RSM (ammonium nitrate solution) applied on a_field owned by a stock farmer.
Definition: farmfuncs.cpp:1111
virtual bool HarvestLong(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: farmfuncs.cpp:1821
CloverGrassGrazed2 * m_CGG2
Definition: farm.h:970
PLWinterBarley * m_plwinterbarley
Definition: farm.h:1053
FarmManager * m_OurManager
Pointer to the FarmManager.
Definition: farm.h:935
OBarleyPeaCloverGrass * m_OBarleyPCG
Definition: farm.h:979
virtual bool AutumnHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the autumn on a_field.
Definition: farmfuncs.cpp:261
WWheatPControl * m_wwheatpcontrol
Definition: farm.h:1029
virtual bool StubbleHarrowing(LE *a_field, double a_user, int a_days)
Carry out stubble harrowing on a_field.
Definition: farmfuncs.cpp:2209
void AddNewEvent(TTypesOfVegetation a_event, long a_date, LE *a_field, int a_todo, long a_num, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_crop)
Adds an event to the event queue for a farm.
Definition: farm.cpp:789
virtual bool FA_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:1036
SpringBarleySKManagement * m_springbarleyskmanagement
Definition: farm.h:1018
NLMaizeSpring * m_nlmaizespring
Definition: farm.h:1085
virtual bool SleepAllDay(LE *a_field, double a_user, int a_days)
Nothing to to today on a_field.
Definition: farmfuncs.cpp:241
PLSpringBarley * m_plspringbarley
Definition: farm.h:1057
void RemoveField(LE *a_field)
Removes a field from a farm.
Definition: farm.cpp:1473
TTypesOfVegetation GetPreviousCrop(int a_index)
Definition: farm.h:909
virtual bool CutWeeds(LE *a_field, double a_user, int a_days)
Carry out weed topping on a_field.
Definition: farmfuncs.cpp:2303
OCloverGrassGrazed2 * m_OCGG2
Definition: farm.h:982
bool IsStockFarmer(void)
Definition: farm.h:905
bool DoIt_prob(double a_probability)
Return chance out of 0 to 1.
Definition: farm.cpp:808
Oats * m_oats
Definition: farm.h:989
NLWinterWheat * m_nlwinterwheat
Definition: farm.h:1075
SpringBarleySilage * m_springbarleysilage
Definition: farm.h:1022
NLGrassGrazed1Spring * m_nlgrassgrazed1spring
Definition: farm.h:1079
virtual bool FA_GreenManure(LE *a_field, double a_user, int a_days)
Spread green manure on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:1062
NLPotatoes * m_nlpotatoes
Definition: farm.h:1073
OFieldPeasSilage * m_ofieldpeassilage
Definition: farm.h:985
int InvIntPartition(vector< tpct > *items, int target)
Finds all possible sums of the integers in the items array.
Definition: farm.cpp:2493
vector< LE * > m_fields
Definition: farm.h:937
OMaizeSilage * m_omaizesilage
Definition: farm.h:978
WinterRyeStrigling * m_winterryestrigling
Definition: farm.h:1042
OWinterRape * m_owinterrape
Definition: farm.h:1002
WinterWheat * m_winterwheat
Definition: farm.h:1028
PermanentGrassLowYield * m_permgrasslowyield
Definition: farm.h:1008
virtual bool FP_Sludge(LE *a_field, double a_user, int a_days)
Spread sewege on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:822
void CheckRotationManagementLoop(FarmEvent *ev)
Definition: farm.cpp:839
NLCarrots * m_nlcarrots
Definition: farm.h:1071
TTypesOfFarm GetType(void)
Definition: farm.h:901
DummyCropPestTesting * m_dummycroppesttesting
Definition: farm.h:1091
BroadBeans * m_broadbeans
Definition: farm.h:967
PLWinterTriticale * m_plwintertriticale
Definition: farm.h:1054
OGrazingPigs * m_ograzingpigs
Definition: farm.h:987
SpringBarley * m_springbarley
Definition: farm.h:1016
NLGrassGrazedLast * m_nlgrassgrazedlast
Definition: farm.h:1081
OPermanentGrassGrazed * m_opermgrassgrazed
Definition: farm.h:991
NLSpringBarleySpring * m_nlspringbarleyspring
Definition: farm.h:1087
virtual bool SpringSow(LE *a_field, double a_user, int a_days)
Carry out a sowing event in the spring on a_field.
Definition: farmfuncs.cpp:546
virtual bool FP_Manure(LE *a_field, double a_user, int a_days)
Spread manure on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:773
PLPotatoes * m_plpotatoes
Definition: farm.h:1060
virtual bool FP_AmmoniumSulphate(LE *a_field, double a_user, int a_days)
Apply Ammonium Sulphate to a_field owned by an arable farmer.
Definition: farmfuncs.cpp:750
virtual bool PigsAreOutForced(LE *a_field, double a_user, int a_days)
Start a pig grazing event on a_field today - no exceptions.
Definition: farmfuncs.cpp:2090
virtual bool BurnStrawStubble(LE *a_field, double a_user, int a_days)
Burn stubble on a_field.
Definition: farmfuncs.cpp:2236
virtual bool CattleIsOut(LE *a_field, double a_user, int a_days, int a_max)
Generate a 'cattle_out' event for every day the cattle are on a_field.
Definition: farmfuncs.cpp:1974
NLCabbage * m_nlcabbage
Definition: farm.h:1076
SetAside * m_setaside
Definition: farm.h:1015
NorwegianSpringBarley * m_norwegianspringbarley
Definition: farm.h:1049
virtual bool FP_ManganeseSulphate(LE *a_field, double a_user, int a_days)
Apply Manganse Sulphate to a_field owned by an arable farmer.
Definition: farmfuncs.cpp:727
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:938
APoint GetValidCoords()
Returns the valid coordinates of the first field owned by a farm.
Definition: farm.h:800
PLWinterWheat * m_plwinterwheat
Definition: farm.h:1051
virtual int GetFirstCropIndex(TTypesOfLandscapeElement a_type)
Gets the first crop for the farm.
Definition: farm.cpp:1385
OSeedGrass1 * m_oseedgrass1
Definition: farm.h:993
virtual bool AutumnPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the autumn on a_field.
Definition: farmfuncs.cpp:132
OWinterBarleyExt * m_owinterbarleyext
Definition: farm.h:1001
PLSpringWheat * m_plspringwheat
Definition: farm.h:1056
virtual bool AutumnRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the autumn on a_field.
Definition: farmfuncs.cpp:288
PLBeetSpr * m_plbeetspr
Definition: farm.h:1067
int GetTotalArea(void)
Returns the area of all fields owned by that farm.
Definition: farm.cpp:1340
virtual bool FP_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:869
virtual bool StubblePlough(LE *a_field, double a_user, int a_days)
Carry out a stubble ploughing event on a_field. This is similar to normal plough but shallow (normall...
Definition: farmfuncs.cpp:169
virtual bool HerbicideTreat(LE *a_field, double a_user, int a_days)
Apply herbicide to a_field.
Definition: farmfuncs.cpp:1156
double GetAreaDouble(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1350
WinterWheatStriglingCulm * m_winterwheatstriglingculm
Definition: farm.h:1034
int m_farm_centroidy
Farm's centroid, value y. Equal to the average of the y centroid values of all farm's fields.
Definition: farm.h:961
NLBeet * m_nlbeet
Definition: farm.h:1070
virtual bool Spraying_herbicides(TTypesOfVegetation)
Definition: farm.h:784
int GetMaxOpenness()
Returns the maximum openness score of the fields.
Definition: farm.h:802
PLFodderLucerne1 * m_plfodderlucerne1
Definition: farm.h:1062
virtual bool ProductApplication(LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp)
Apply test pesticide to a_field.
Definition: farmfuncs.cpp:1445
virtual bool FP_NPK(LE *a_field, double a_user, int a_days)
Apply NPK fertilizer, on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:629
WWheatPTreatment * m_wwheatptreatment
Definition: farm.h:1031
SpringRape * m_springrape
Definition: farm.h:1023
PLBeans * m_plbeans
Definition: farm.h:1068
FodderGrass * m_foddergrass
Definition: farm.h:968
PLSpringBarleySpr * m_plspringbarleyspr
Definition: farm.h:1065
virtual bool CutToHay(LE *a_field, double a_user, int a_days)
Carry out hay cutting on a_field.
Definition: farmfuncs.cpp:2269
virtual int GetNextCropIndex(int a_rot_index)
Returns the next crop in the rotation.
Definition: farm.cpp:1427
WinterRye * m_winterrye
Definition: farm.h:1027
MaizeStrigling * m_maizestrigling
Definition: farm.h:1040
virtual double Prob_multiplier()
Definition: farm.h:786
virtual bool HillingUp(LE *a_field, double a_user, int a_days)
Do hilling up on a_field, probably of potatoes.
Definition: farmfuncs.cpp:1663
SpringBarleyPTreatment * m_springbarleyptreatment
Definition: farm.h:1019
virtual bool FlowerCutting(LE *a_field, double a_user, int a_days)
Flower cutting applied on a_field.
Definition: farmfuncs.cpp:2437
WinterBarley * m_winterbarley
Definition: farm.h:1025
virtual bool PreseedingCultivatorSow(LE *a_field, double a_user, int a_days)
Carry out preseeding cultivation together with sow on a_field (tilling and sowing set including culti...
Definition: farmfuncs.cpp:337
int GetNextCropStartDate(LE *a_field, TTypesOfVegetation &a_curr_veg)
Returns the start date of the next crop in the rotation.
Definition: farm.cpp:864
virtual bool BedForming(LE *a_field, double a_user, int a_days)
Do bed forming up on a_field, probably of carrots.
Definition: farmfuncs.cpp:1690
TTypesOfVegetation GetCrop(int a_index)
Definition: farm.h:914
OCloverGrassSilage1 * m_OCGS1
Definition: farm.h:983
virtual bool GrowthRegulator(LE *a_field, double a_user, int a_days)
Apply growth regulator to a_field.
Definition: farmfuncs.cpp:1250
virtual bool HeavyCultivatorAggregate(LE *a_field, double a_user, int a_days)
Carry out a heavy cultivation event on a_field. This is non-inversion type of cultivation which can b...
Definition: farmfuncs.cpp:217
OCloverGrassGrazed1 * m_OCGG1
Definition: farm.h:981
virtual bool Biocide(LE *a_field, double a_user, int a_days)
Biocide applied on a_field.
Definition: farmfuncs.cpp:2415
NLCatchPeaCrop * m_nlcatchpeacrop
Definition: farm.h:1089
NLPotatoesSpring * m_nlpotatoesspring
Definition: farm.h:1086
virtual bool FP_Slurry(LE *a_field, double a_user, int a_days)
Apply slurry to a_field owned by an arable farmer.
Definition: farmfuncs.cpp:701
virtual bool StrawCovering(LE *a_field, double a_user, int a_days)
Straw covering applied on a_field.
Definition: farmfuncs.cpp:2502
virtual bool StrawRemoval(LE *a_field, double a_user, int a_days)
Straw covering applied on a_field.
Definition: farmfuncs.cpp:2524
OFirstYearDanger * m_ofirstyeardanger
Definition: farm.h:986
virtual bool FA_ManganeseSulphate(LE *a_field, double a_user, int a_days)
Apply manganese sulphate to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:1013
virtual bool FA_Sludge(LE *a_field, double a_user, int a_days)
Spread sewege sludge on a_field owned by an stock farmer.
Definition: farmfuncs.cpp:1086
OFodderbeet * m_ofodderbeet
Definition: farm.h:975
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
Definition: farm.h:1039
virtual bool FP_RSM(LE *a_field, double a_user, int a_days)
RSM (ammonium nitrate solution) applied on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:847
OSpringBarley * m_ospringbarley
Definition: farm.h:995
SpringBarleyStriglingCulm * m_springbarleystriglingculm
Definition: farm.h:1038
OrchardCrop * m_orchardcrop
Definition: farm.h:988
virtual void Management(void)
Starts the main management loop for the farm and performs some error checking.
Definition: farm.cpp:361
virtual bool StubbleCultivatorHeavy(LE *a_field, double a_user, int a_days)
Carry out a stubble cultivation event on a_field. This is non-inversion type of cultivation which can...
Definition: farmfuncs.cpp:193
WinterWheatStrigling * m_winterwheatstrigling
Definition: farm.h:1033
PotatoesIndustry * m_potatoesindustry
Definition: farm.h:1012
void Assign_rotation(vector< TTypesOfVegetation >a_new_rotation)
Definition: farm.cpp:1488
virtual bool FA_AmmoniumSulphate(LE *a_field, double a_user, int a_days)
Apply ammonium sulphate to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:990
int GetIntensity(void)
Definition: farm.h:907
Fodderbeet * m_fodderbeet
Definition: farm.h:973
int GetArea(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1331
LowPriority< FarmEvent * > m_queue
Definition: farm.h:936
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
Definition: farm.h:1036
virtual bool SpringHarrow(LE *a_field, double a_user, int a_days)
Carry out a harrow event in the spring on a_field.
Definition: farmfuncs.cpp:471
virtual bool PigsOut(LE *a_field, double a_user, int a_days)
Generate a 'pigs_out' event for every day the cattle are on a_field.
Definition: farmfuncs.cpp:2062
OSpringBarleyExt * m_ospringbarleyext
Definition: farm.h:996
PLWinterRye * m_plwinterrye
Definition: farm.h:1055
FieldPeasStrigling * m_fieldpeasstrigling
Definition: farm.h:1044
OWinterBarley * m_owinterbarley
Definition: farm.h:1000
APoint GetCentroids()
Definition: farm.h:908
SpringBarleySpr * m_springbarleyspr
Definition: farm.h:1017
NLCabbageSpring * m_nlcabbagespring
Definition: farm.h:1088
SpringBarleySeed * m_springbarleyseed
Definition: farm.h:1021
virtual bool SpringRoll(LE *a_field, double a_user, int a_days)
Carry out a roll event in the spring on a_field.
Definition: farmfuncs.cpp:525
NLCarrotsSpring * m_nlcarrotsspring
Definition: farm.h:1084
NLGrassGrazed1 * m_nlgrassgrazed1
Definition: farm.h:1078
HunterList m_HuntersList
A list of hunters allocated to this farm.
Definition: farm.h:942
virtual bool Strigling(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field.
Definition: farmfuncs.cpp:1545
OWinterWheatUndersown * m_owinterwheatundersown
Definition: farm.h:1004
OTriticale * m_otriticale
Definition: farm.h:999
Triticale * m_triticale
Definition: farm.h:1024
virtual bool AutumnSow(LE *a_field, double a_user, int a_days)
Carry out a sowing event in the autumn on a_field.
Definition: farmfuncs.cpp:364
SpringBarleyStrigling * m_springbarleystrigling
Definition: farm.h:1037
NorwegianPotatoes * m_norwegianpotatoes
Definition: farm.h:1047
virtual bool StrawChopping(LE *a_field, double a_user, int a_days)
Carry out straw chopping on a_field.
Definition: farmfuncs.cpp:2132
WWheatPToxicControl * m_wwheatptoxiccontrol
Definition: farm.h:1030
Sugarbeet * m_sugarbeet
Definition: farm.h:974
virtual bool FA_NPKS(LE *a_field, double a_user, int a_days)
Apply NPKS fertilizer, on a_field owned by a stock farmer.
Definition: farmfuncs.cpp:891
FieldPeas * m_fieldpeas
Definition: farm.h:971
virtual bool StriglingHill(LE *a_field, double a_user, int a_days)
Carry out a mechanical weeding on a_field followed by hilling up (probably on potatoes)
Definition: farmfuncs.cpp:1635
NLGrassGrazed2 * m_nlgrassgrazed2
Definition: farm.h:1080
PLWinterRape * m_plwinterrape
Definition: farm.h:1052
OWinterWheat * m_owinterwheat
Definition: farm.h:1005
virtual bool FP_NPKS(LE *a_field, double a_user, int a_days)
Apply NPKS fertilizer, on a_field owned by an arable farmer.
Definition: farmfuncs.cpp:602
YoungForestCrop * m_youngforest
Definition: farm.h:1046
WinterBarleyStrigling * m_winterbarleystrigling
Definition: farm.h:1043
FieldPeasSilage * m_fieldpeassilage
Definition: farm.h:972
virtual void HandleEvents(void)
If there are events to carry out do this, and perhaps start a new crop.
Definition: farm.cpp:882
PermanentGrassTussocky * m_permgrasstussocky
Definition: farm.h:1009
virtual bool FungicideTreat(LE *a_field, double a_user, int a_days)
Apply fungicide to a_field.
Definition: farmfuncs.cpp:1279
bool m_stockfarmer
Definition: farm.h:943
void SetFarmNumber(int a_farm_num)
Definition: farm.h:781
virtual bool BulbHarvest(LE *a_field, double a_user, int a_days)
Carry out a bulb harvest on a_field.
Definition: farmfuncs.cpp:2465
virtual bool WinterPlough(LE *a_field, double a_user, int a_days)
Carry out a ploughing event in the winter on a_field.
Definition: farmfuncs.cpp:392
int m_farm_num
Definition: farm.h:944
NLPermanentGrassGrazed * m_nlpermanentgrassgrazed
Definition: farm.h:1082
virtual bool FA_Calcium(LE *a_field, double a_user, int a_days)
Calcium applied on a_field owned by a stock farmer.
Definition: farmfuncs.cpp:1133
OOats * m_ooats
Definition: farm.h:990
int GetNoOpenFields(int a_openness)
Returns the number of the fields above an openness of a_openness.
Definition: farm.cpp:1359
PLBeet * m_plbeet
Definition: farm.h:1061
OSpringBarleyPigs * m_ospringbarleypigs
Definition: farm.h:997
virtual bool DeepPlough(LE *a_field, double a_user, int a_days)
Carry out a deep ploughing event on a_field.
Definition: farmfuncs.cpp:417
int GetNoFields()
Returns the number of the fields owned.
Definition: farm.h:794
virtual bool Water(LE *a_field, double a_user, int a_days)
Carry out a watering on a_field.
Definition: farmfuncs.cpp:1717
TTypesOfVegetation GetNextCrop(int a_index)
Definition: farm.h:917
virtual bool Swathing(LE *a_field, double a_user, int a_days)
Cut the crop on a_field and leave it lying (probably rape)
Definition: farmfuncs.cpp:1744
Maize * m_maize
Definition: farm.h:976
virtual bool InsecticideTreat(LE *a_field, double a_user, int a_days)
Apply insecticide to a_field.
Definition: farmfuncs.cpp:1348
Farm(FarmManager *a_manager)
Farm constructor - creates an instance of each possible crop type.
Definition: farm.cpp:1058
NLSpringBarley * m_nlspringbarley
Definition: farm.h:1074
virtual ~Farm(void)
Farm destructor - deletes all crop instances and empties event queues.
Definition: farm.cpp:1199
int m_farm_centroidx
Farm's centroid, value x. Equal to the average of the x centroid values of all farm's fields.
Definition: farm.h:959
int m_rotation_sync_index
Definition: farm.h:945
virtual bool CutOrch(LE *a_field, double a_user, int a_days)
Cut vegetation on orchard crop. //based on cut to silage - values from cutting function of orchard.
Definition: farmfuncs.cpp:2362
PLCarrots * m_plcarrots
Definition: farm.h:1064
AgroChemIndustryCereal * m_agrochemindustrycereal
Definition: farm.h:1032
virtual bool Harvest(LE *a_field, double a_user, int a_days)
Carry out a harvest on a_field.
Definition: farmfuncs.cpp:1769
virtual bool ProductApplication_DateLimited(LE *a_field, double, int, double a_applicationrate, PlantProtectionProducts a_ppp)
Special pesticide trial functionality.
Definition: farmfuncs.cpp:2396
NLTulips * m_nltulips
Definition: farm.h:1077
void AssignPermanentCrop(TTypesOfVegetation tov, int pct)
Used to assign a permanent crop to an otherwise rotational field polygon.
Definition: farm.cpp:2401
PLFodderLucerne2 * m_plfodderlucerne2
Definition: farm.h:1063
PLWinterWheatLate * m_plwinterwheatlate
Definition: farm.h:1066
OSBarleySilage * m_osbarleysilage
Definition: farm.h:998
PermanentGrassGrazed * m_permgrassgrazed
Definition: farm.h:1007
SeedGrass1 * m_seedgrass1
Definition: farm.h:1013
virtual bool Molluscicide(LE *a_field, double a_user, int a_days)
Apply molluscidie to a_field.
Definition: farmfuncs.cpp:1481
TTypesOfFarm m_farmtype
Definition: farm.h:940
NorwegianOats * m_norwegianoats
Definition: farm.h:1048
virtual bool CattleIsOutLow(LE *a_field, double a_user, int a_days, int a_max)
Generate a 'cattle_out_low' event for every day the cattle are on a_field.
Definition: farmfuncs.cpp:2018
Carrots * m_carrots
Definition: farm.h:966
OFieldPeas * m_ofieldpeas
Definition: farm.h:984
void AddHunter(Hunter *a_hunter)
Definition: farm.h:922
virtual bool FA_PK(LE *a_field, double a_user, int a_days)
Apply PK fertilizer to a_field owned by an stock farmer.
Definition: farmfuncs.cpp:941
CloverGrassGrazed1 * m_CGG1
Definition: farm.h:969
virtual bool PreseedingCultivator(LE *a_field, double a_user, int a_days)
Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to co...
Definition: farmfuncs.cpp:311
PermanentSetAside * m_permanentsetaside
Definition: farm.h:1010
SpringBarleyCloverGrass * m_sbarleyclovergrass
Definition: farm.h:1020
virtual bool SpringSowWithFerti(LE *a_field, double a_user, int a_days)
Carry out a sowing event with start fertilizer in the spring on a_field.
Definition: farmfuncs.cpp:574
The Farm Manager class.
Definition: farm.h:1707
vector< double > m_crops_fertilizer_trade
Stores information on aggregate (all farms) fertilizer trade (Nt) usage for each crop.
Definition: farm.h:1955
void Add_to_cropTotals(int i, double value)
Definition: farm.h:1838
vector< PesticideData > m_crops_summary_BIs
Stores information on aggregate (all farms)pesticide usage for each crop.
Definition: farm.h:1951
void Set_cropTotals(int i, double value)
Definition: farm.h:1839
void InitFarms()
Calls OptimisingFarm::Init for all optimising farms.
Definition: farm.cpp:3014
int FindClosestFarmOpennessProb(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness)
Finds the closest farm to this co-ordinate with openness more than a value but uses a probability dis...
Definition: farm.cpp:3182
void PrintNeighbours()
Creates an output file with a list of neighbours of each OptimisingFarm.
Definition: farm.cpp:4701
void FarmManagement()
Runs the daily farm management for each farm, but also calculates annual spilled grain and maize.
Definition: farm.cpp:2707
void ActualProfit()
Calls OptimisingFarm::ActualProfit for all optimising farms.
Definition: farm.cpp:3433
void Set_crops_fertilizer_trade(int i, double fert_trade)
Definition: farm.h:1864
int GetFarmNoOpenFields(int a_farmref, int a_openness)
Returns the number of fields with openness more than a_openness.
Definition: farm.h:1754
double GetSpilledGrain()
Returns the average amount of spilled grain in KJ/m2 this year.
Definition: farm.cpp:3033
void ReadCropsData_perFarmType()
Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them ...
Definition: farm.cpp:3881
TTypesOfSoils TranslateSoilCodes(string &str)
Definition: farm.cpp:4286
void Set_cropTotals_other_sum(int i, double crop_area)
Definition: farm.h:1861
void DumpFarmAreas()
Definition: farm.cpp:1964
vector< double > m_cropTotals_sum
Stores the sums of crops areas within one simulation at the landscape level.
Definition: farm.h:1941
void ReadCropsData_perFarm_and_Soil_almass()
Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them...
Definition: farm.cpp:4036
void Set_cropTotals_sum(int i, double crop_area)
Definition: farm.h:1857
bool InIllegalList(int a_farm_ref, vector< int > *a_farmlist)
Checks a list to see if a farm matches the illegal list of references.
Definition: farm.cpp:3088
void ReadCropsData_perFarm_and_Soil_and_Size()
Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax,...
Definition: farm.cpp:4074
void Set_cropTotals_pig_sum(int i, double crop_area)
Definition: farm.h:1859
vector< double > m_cropTotals_pig_sum
Stores the sums of crops areas on pig farms within one simulation at the landscape level.
Definition: farm.h:1945
bool m_SpilledGrain
Is it 2013 (true) or 2014 (false) as far as grain goes.
Definition: farm.h:1912
void ReadCropsData_perFarm_and_Soil_and_Size_almass()
Reads the data on crops' parameters that vary with a farm type, soil type and farm size (rotationMax,...
Definition: farm.cpp:4117
void ReadFarmsData_perFarmType()
Reads the data on farms' parameters that vary with a farm type and saves them in a vector of a DataFo...
Definition: farm.cpp:4184
bool m_renumbered
A flag to show whether renumbering was already done.
Definition: farm.h:1917
int GetNoFarms()
Definition: farm.h:1900
void CreateFarms(const char *a_farmfile)
Definition: farm.cpp:2772
TTypesOfFarmSize TranslateFarmSizeCodes(string &str)
Definition: farm.cpp:4298
DataForOptimisation * pm_data
Pointer to the DataForOptimisation.
Definition: farm.h:1876
void ReadEnergyMaizePrice()
Definition: farm.cpp:4244
void ReadCropsData_perFarm_and_Soil()
Reads the data on crops' parameters that vary with a farm and soil type (sellingPrice) and saves them...
Definition: farm.cpp:4003
void ReadInitialCropAreas_almass()
Reads the data on farms' initial crop distributions and saves them in a vector of a DataForOptimisati...
Definition: farm.cpp:3612
TTypesOfLivestockParameters TranslateLivestockParametersCodes(string &str)
Definition: farm.cpp:4414
void ReadCropsData()
Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector D...
Definition: farm.cpp:3656
double totalOptFarmsArea_cattle
Definition: farm.h:1933
void Set_cropTotals_plant_sum(int i, double crop_area)
Definition: farm.h:1858
APoint GetFarmCentroid(int a_farmref)
Gets the farm centroid as an APoint.
Definition: farm.h:1809
~FarmManager()
Farm manager destructor.
Definition: farm.cpp:2699
TTypesOfParameters TranslateParametersCodes(string &str)
Definition: farm.cpp:4387
int FindClosestFarmOpenness(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness)
Finds the closest farm to this co-ordinate but uses a probability distribtution for acceptance.
Definition: farm.cpp:3155
int GetFarmNoFields(int a_farmref)
Returns the number of fields owned by a from the farm ref num.
Definition: farm.h:1743
void ChooseDecisionMode_for_farms()
Calls OptimisingFarm::ChooseDecisionMode for all optimising farms.
Definition: farm.cpp:3444
bool CheckOpenness(int a_openness, int a_ref)
Check if a farm has at least one field with openness above a_openness.
Definition: farm.cpp:3399
Population_Manager * m_population_manager
Definition: farm.h:1907
void ReadInitialCropAreas()
Reads the data on farms' initial crop distributions and saves them in a vector DataForOptimisation::m...
Definition: farm.cpp:3571
TTypesOfFarm GetFarmType(int a_farmref)
Returns the farm type from the farm ref num.
Definition: farm.h:1738
double GetSpilledMaize()
Returns the average amount of spilled maize in KJ/m2 this year.
Definition: farm.cpp:3064
int FindFarmWithOpenness(vector< int > *a_farmlist, int a_openness)
Finds a farm openness more than a value not on the list.
Definition: farm.cpp:3370
FarmManager()
Farm manager constructor.
Definition: farm.cpp:2626
void Set_crops_summary_BIs(int i, double BI)
Definition: farm.h:1856
void ReadCropsData_perSoilType()
Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2,...
Definition: farm.cpp:3724
void CalcCentroids()
calculate all farm centroids
Definition: farm.h:1783
int * m_farmmapping_lookup
Used for a dynamic array of lookups converting farm references to internal renumbering.
Definition: farm.h:1915
void ReadCropsData_perFarmType_almass()
Reads the data on crops' parameters that vary with a farm type (fixed, fodder, FUKey) and saves them ...
Definition: farm.cpp:3937
void Set_crops_summary_BIs_herb(int i, double BIherb)
Definition: farm.h:1854
void PrintOutput(TTypesOfCropVariables a_var, string a_fileName)
Makes an output file for one crop variable and prints its values for each crop and each OptimisingFar...
Definition: farm.cpp:4504
void OptimisationOutput()
Creates output files for all crop level variables and for landscape level crop distribution....
Definition: farm.cpp:4451
void Save_last_years_crops_for_farms()
Calls OptimisingFarm::Save_last_years_crops for all optimising farms.
Definition: farm.cpp:3456
void InitiateManagement(void)
Definition: farm.cpp:2733
Farm * GetFarmPtr(int a_owner)
Returns the pointer to a farm with a specific number.
Definition: farm.h:1766
vector< Farm * > m_farms
Definition: farm.h:1906
int ConnectFarm(int a_owner)
Definition: farm.cpp:2752
int FindClosestFarm(HunterInfo a_hinfo, vector< int > *a_farmlist)
Finds the closest farm to this co-ordinate.
Definition: farm.cpp:3126
vector< double > m_cropTotals
Stores crops areas at the landscape level per year.
Definition: farm.h:1937
TTypesOfOptFarms TranslateFarmCodes(string &str)
Definition: farm.cpp:4273
void Save_diff_farm_types_areas()
Calculates and saves total areas of all optimising farms and specific farm types.
Definition: farm.cpp:3404
double totalOptFarmsArea
Definition: farm.h:1930
TTypesOfCropVariables TranslateCropVariablesCodes(string &str)
Definition: farm.cpp:4426
void Set_crops_summary_BIs_fi(int i, double BIfi)
Definition: farm.h:1855
double GetDD(void)
Returnes day degrees for the period March 1st - November 1st. Used for determining yields of crops th...
Definition: farm.h:1835
void ReadLookupTable()
Reads the lookup table with allowed/forbidden crop order from a text file and saves it into a vector ...
Definition: farm.cpp:4625
vector< int > m_crop_lookup_table
Specifies which crop order is allowed in a rotation (i.e. if a given crop can follow another crop).
Definition: farm.h:1939
double totalOptFarmsArea_plant
Definition: farm.h:1931
void Create_Output_file_for_farms()
Creates an output file. Prints the crop variables in the first row of the file. The file is used then...
Definition: farm.cpp:4609
double totalOptFarmsArea_other
Definition: farm.h:1934
void Set_cropTotals_cattle_sum(int i, double crop_area)
Definition: farm.h:1860
APoint GetFarmValidCoords(int a_farmref)
Returns the number of fields owned by a from the farm ref num.
Definition: farm.h:1748
TTypesOfVegetation Get_crops_summary_BIs_tov(int i)
Definition: farm.h:1853
int FindClosestFarmOpennessProbSmallIsBest(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness, vector< int > *a_farmsizelist)
Finds the closest farm to this co-ordinate with openness more than a value but uses a probability dis...
Definition: farm.cpp:3233
void ReadCropsData_perSoilType_almass()
Reads the data on crops' parameters that vary with a soil type (alfa, beta1, beta2,...
Definition: farm.cpp:3790
int GetFarmAreaOpenFields(int a_farmref, int a_openness)
Returns the area of fields with openness more than a_openness.
Definition: farm.h:1760
int GetFarmArableSize(int a_farmref)
Returns the arable area from the farm ref num.
Definition: farm.h:1733
int FindOpennessFarm(int a_openness)
Finds a random farm with at least one field with openness above a_openness.
Definition: farm.cpp:3387
void AddToIllegalList(int a_farm_ref, vector< int > *a_farmlist)
Add to a list if a farm is not already among the illegal list of references.
Definition: farm.cpp:3099
void AddField(int a_OwnerIndex, LE *a_newland, int a_Owner)
Definition: farm.cpp:2741
TTypesOfVegetation TranslateCropCodes(std::string &str)
Definition: farm.cpp:1818
bool IsDuplicateRef(int a_ref, HunterInfo *a_hinfo)
Checks if we already have this ref.
Definition: farm.cpp:3116
double daydegrees
Daydegress for period March 1st - November 1st. Used to determine yield of crops that are not harvest...
Definition: farm.h:1910
void Set_crops_fertilizer(int i, double fert)
Definition: farm.h:1863
void FindNeighbours()
Finds all OptimisingFarms' neighbours and saves them in the farm's OptimisingFarm::m_neighbours vecto...
Definition: farm.cpp:4657
int Get_lookup_table(int index)
Definition: farm.h:1879
TTypesOfCrops TranslateCropsCodes(string &str)
Definition: farm.cpp:4338
vector< double > m_cropTotals_other_sum
Stores the sums of crops areas on other farms within one simulation at the landscape level.
Definition: farm.h:1949
int GetFarmTotalSize(int a_farmref)
Returns the total farm area from the farm ref num.
Definition: farm.h:1728
int GetRandomFarmRefnum()
Returns a random farm reference number.
Definition: farm.h:1781
vector< double > m_cropTotals_cattle_sum
Stores the sums of crops areas on cattle farms within one simulation at the landscape level.
Definition: farm.h:1947
void CropDistribution()
Calculates total crop areas (at the landscape level). Includes results of the initial farm otpimisati...
Definition: farm.cpp:4588
vector< double > m_crops_fertilizer
Stores information on aggregate (all farms) fertilizer usage for each crop.
Definition: farm.h:1953
int GetFarmNoLookup(int a_ref)
Get a farm reference from the lookup table.
Definition: farm.h:1882
void Switch_rotation()
Switches OptimisingFarms Farm::m_rotation to the list of all possible rotational crops.
Definition: farm.cpp:4942
int FindClosestFarmOpennessProbNearRoostIsBest(HunterInfo a_hinfo, vector< int > *a_farmlist, int a_openness, vector< APoint > *a_farmsizelist)
Finds the closest farm to this co-ordinate with openness more than a value but uses a probability dis...
Definition: farm.cpp:3289
vector< double > m_cropTotals_plant_sum
Stores the sums of crops areas on plant farms within one simulation at the landscape level.
Definition: farm.h:1943
void ReadLivestockData()
Reads the data on livestock parameters (do not vary with farm variables) and saves them in a vector D...
Definition: farm.cpp:4212
int Get_cropTotals_size()
Definition: farm.h:1840
int GetRenumberedFarmRef(int a_farmref)
Returns the farm ref index for a farmref.
Definition: farm.h:1888
ofstream * pm_output_file
Definition: farm.h:1877
double totalOptFarmsArea_pig
Definition: farm.h:1932
Farm * GetFarmPtrIndex(int a_index)
Returns the pointer to a farm with a specific index.
Definition: farm.h:1777
int FindFarmWithRandom(vector< int > *a_farmlist)
Finds a farm openness more than a value not on the list.
Definition: farm.cpp:3353
void SetDD(double a_dd)
Definition: farm.h:1836
vector< double > m_crop_areas_stages
Stores information on crop areas calculated in different stages of model development: for comparison ...
Definition: farm.h:1957
void ReadFarmsData()
Reads farm level parameters and saves them in a vector DataForOptimisation::m_farm_data.
Definition: farm.cpp:3484
double Get_cropTotals(int i)
Definition: farm.h:1837
void PrintFinalResults()
At the end of a simulation it prints results on crop distribution, pesticide and fertilizer usage.
Definition: farm.cpp:4741
void SetSpilledGrain(bool a_spilledgrain)
Set m_SpilledGrain which is the flag for either 2013 (true) or 2014 (false) spilled grain distributio...
Definition: farm.h:1828
void ReadCropsData_almass()
Reads the data on crops' parameters that do not vary with farm variables and saves them in a vector D...
Definition: farm.cpp:3688
TTypesOfAnimals TranslateAnimalsCodes(string &str)
Definition: farm.cpp:4309
void DistributeFarmerTypes()
Randomly assigns farmer types to farms (OptimisingFarm) in proportions specified in an input file.
Definition: farm.cpp:4965
int GetFarmTypeLookup(int a_ref)
Get a farm type from the lookup table.
Definition: farm.h:1884
bool GetIsRenumbered()
Returns the flag for renumbering.
Definition: farm.h:1886
void ReadLivestockNumbers()
Reads the data on livestock numbers and saves them in a vector DataForOptimisation::m_livestockNumber...
Definition: farm.cpp:3530
void DumpFarmrefs()
dumps the farmrefs file to a standard named file
Definition: farm.cpp:2997
void RemoveField(int a_OwnerIndex, LE *a_field)
Definition: farm.cpp:2747
void PrintDecModes_counts()
For each OptimizingFarm it prints the number of times each of the decision modes was used within a si...
Definition: farm.cpp:4720
The base class for hunters encompsassing all their general behaviours.
Definition: Hunters_all.h:121
A data structure to hold hunter information for distribution.
Definition: farm.h:511
vector< int > FarmHuntRef
The hunter's is the farm reference number to where he hunts.
Definition: farm.h:520
~HunterInfo()
Definition: farm.h:524
int homeY
Hunter home y-coord.
Definition: farm.h:518
int refID
Unique reference number.
Definition: farm.h:514
vector< int > CheckedFarms
A list of farms that has been tested for duplicates.
Definition: farm.h:522
int homeX
Hunter home x-coord.
Definition: farm.h:516
Definition: elements.h:81
A class for storing livestock parameters and variables for optimising farms.
Definition: farm.h:1617
Livestock(TTypesOfAnimals a_animalType, int a_number)
Constructor.
Definition: farm.cpp:5094
TTypesOfAnimals m_animalType
Type of livestock.
Definition: farm.h:1622
int m_number
Number of animals of a given type at a farm.
Definition: farm.h:1624
double m_FUdemand
Amount of fodder needed for a given type of livestock. [fodder units].
Definition: farm.h:1628
double m_NanimUsable
Amount of usable animal fertilizer from a given type of livestock. [kg].
Definition: farm.h:1626
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
Inbuilt special purpose farm type.
Definition: farm.h:1242
NoPesticideBaseFarm(FarmManager *a_manager)
Definition: farm.cpp:2148
Inbuilt special purpose farm type.
Definition: farm.h:1251
NoPesticideNoPFarm(FarmManager *a_manager)
Definition: farm.cpp:2193
Subclass of the OptimisingFarm. Either plant or other farm.
Definition: farm.h:2475
NonAnimalFarm(FarmManager *a_myfarmmanager, int a_No)
Definition: farm.cpp:5276
virtual void checkWinterCrops()
Checks if the restriction on a max. share of winter crops is fulfilled.
Definition: farm.cpp:6836
virtual void checkWinterRotation1()
Checks if the restriction on a winter rotation is fulfilled.
Definition: farm.cpp:6469
virtual ~NonAnimalFarm()
Definition: farm.h:2478
virtual void findFodderDemand()
Determines farm's total demand for fodder (m_totalFUdemand).
Definition: farm.cpp:5693
Subclass of the AnimalFarm.
Definition: farm.h:2448
virtual ~OptimisingCattleFarm()
Definition: farm.h:2451
void setCattleCropsAtMin()
Decreases area of cattle crops to their min. required area.
Definition: farm.cpp:7027
virtual void preventCashCrops()
Prevents small cattle farms from growing cash crops and maize silage.
Definition: farm.cpp:5704
OptimisingCattleFarm(FarmManager *a_myfarmmanager, int a_No)
Definition: farm.cpp:5284
vector< CropSort > m_cattleCrops_almass
Vector of crops used in checkCattleRotation_almass.
Definition: farm.h:2457
virtual void checkRestrictions()
Checks if the restrictions are fulfilled and corrects crops' areas if necessary.
Definition: farm.cpp:6442
vector< CropSort > m_cattleCrops
Vector of crops used in checkCattleRotation.
Definition: farm.h:2451
void checkCattleRotation_almass()
Checks if the cattle restriction is fulfilled - in the ALMaSS crops mode.
Definition: farm.cpp:7304
void checkCattleRotation()
Checks if the cattle restriction is fulfilled - in the Bedriftsmodel (original farm optimization mode...
Definition: farm.cpp:7053
A farm that carries out crop, pesticide and fertilizer planning using simplified optimisation or othe...
Definition: farm.h:2029
double m_actual_aggregated_yield
Actual aggregated yield at a farm in a given year.
Definition: farm.h:2131
vector< CropSort > m_variableCrops
Vector of structs containing pointers to crops which are not fixed.
Definition: farm.h:2185
vector< int > m_decision_mode_counters
Vector with counters for each decision mode. 0 - imitation, 1 - social comparison,...
Definition: farm.h:2114
double crop_parameter(int index, string par_name)
Reads in crop parameters that do NOT vary with any farm level parameters.
Definition: farm.cpp:7756
double m_totalArea_original
Total area of a farm as in bedriftsmodel, i.e. original farm optimization model. [ha].
Definition: farm.h:2226
void sortCrops(vector< CropSort > &cropsToSort, string sortingKey)
Sorts structs of type CropSort.
Definition: farm.cpp:7788
virtual bool InsecticideTreat(LE *a_field, double, int a_days)
Carries out insecticide application. Saves information on each application for a given crop.
Definition: farmfuncs.cpp:1389
void Save_last_years_crops()
It saves the OptimisingFarm::m_rotational_crops in a vector m_rotational_crops_visible which is acces...
Definition: farm.cpp:5472
vector< CropOptimised * > m_grownVariableCrops
Vector of pointers to variable crops that are grown on area larger than areaMin (after determineAreas...
Definition: farm.h:2192
double m_area_scaling_factor
Factor used to scale areas of fixed crops and livestock numbers. Used to adjust these values to the f...
Definition: farm.h:2228
void Set_Crop(CropOptimised *p_crop)
Definition: farm.h:2043
int GetFarmCentroidX()
Definition: farm.h:2055
vector< CropOptimised * > m_crops
Vector of pointers to all crops.
Definition: farm.h:2183
vector< double > m_previous_profits
Vector of profits from previous years.
Definition: farm.h:2137
int GetFarmCentroidY()
Definition: farm.h:2056
void ChooseDecisionMode()
Function determines which decision mode to use. The choice depends on the values of need satisfaction...
Definition: farm.cpp:5478
void findGrossMargin(CropOptimised *a_crop, int a_foobar, double benefit)
Determines the gross margin (CropOptimised::m_GM) for a given crop at a farm.
Definition: farm.cpp:6225
void Set_animals_no(int a_number)
Definition: farm.h:2059
virtual void increaseCrops(vector< CropSort >cropsToIncrease, double &howMuchToIncrease)
Increases area of crops by a specified number.
Definition: farm.cpp:7854
vector< AlmassCrop > m_rotational_crops_visible
Stores a copy of m_rotational_crops from a previous year and is accessible to farmers who want to cop...
Definition: farm.h:2206
double m_need_satisfaction_level
Farmer's actual satisfaction level.
Definition: farm.h:2110
double m_totalProfit
Planned total profit (= income - costs) at a farm. In case of animal farms costs of purchased fodder ...
Definition: farm.h:2264
virtual bool FungicideTreat(LE *a_field, double, int a_days)
Carries out fungicide application. Saves information on each application for a given crop.
Definition: farmfuncs.cpp:1307
double m_totalBIFi
Total amount of fung- and insecticides which is planned to be applied at a farm. Expressed as a Treat...
Definition: farm.h:2250
int Get_cropsSize(void)
Definition: farm.h:2041
double m_area_rot
Area assigned to rotational crops. [ha].
Definition: farm.h:2266
double m_actual_profit
An actual profit realised at a farm in a given year.
Definition: farm.h:2118
void sumMinAreas()
Adds minimum required areas of variable crops to the variable m_assigned.
Definition: farm.cpp:6294
void Make_rotational_crops()
Creates a vector m_rotational_crops using the results of optimisation.
Definition: farm.cpp:8285
double m_totalN
Total amount of fertilizer used at a farm. [kg].
Definition: farm.h:2244
double m_actual_income
An actual income at a farm in a given year.
Definition: farm.h:2122
virtual bool Spraying_herbicides(TTypesOfVegetation a_tov_type)
Returns true if a farmer decided to treat a given crop with herbicides.
Definition: farm.cpp:5348
void findFertilizer(CropOptimised *a_crop, int a_foobar, double benefit)
Determines the optimal amounts of: total fertilizer (CropOptimised::m_n) and purchased fertilizer (Cr...
Definition: farm.cpp:5906
double m_totalFUgrown
Fodder grown, i.e. obtained from growing fodder crops. [fodder units].
Definition: farm.h:2240
double m_exp_costs
Expected costs at a farm in a given year.
Definition: farm.h:2128
void OptimiseFarm(int a_foobar)
Carries out the whole farm optimisation.
Definition: farm.cpp:5765
int Get_soilSubType(void)
Definition: farm.h:2038
void findBIs(CropOptimised *a_crop, double benefit)
Determines the optimal Treatment frequency indices (behandling index, BI in Danish) (CropOptimised::m...
Definition: farm.cpp:6047
double m_totalHoeing
Total hoeing planned at a farm.
Definition: farm.h:2256
TTypesOfOptFarms m_farmType
Farm's type (cattle, pig, plant, other).
Definition: farm.h:2210
int m_almass_no
Farm's almass number.
Definition: farm.h:2220
bool Harvest(LE *a_field, double a_user, int a_days)
OptimisingFarm's virtual version of Farm::Harvest(). Saves information on biomass of a crop at harves...
Definition: farmfuncs.cpp:1859
void fixBI()
Sets values of Treatment frequency indices (BI) for crops with fixed amount of pesticides (CropOptimi...
Definition: farm.cpp:6123
TTypeOfFarmerGoal m_main_goal
Farmer's main goal (determined by a farmer's type) .
Definition: farm.h:2103
vector< AlmassCrop > Get_rotational_crops_visible()
Definition: farm.h:2052
void Make_rotations()
Creates m_rotation. Not used in ALMaSS crop mode.
Definition: farm.cpp:8403
virtual void determineAreas(int a_foobar)
Determines areas of variable crops.
Definition: farm.cpp:6304
void findTotalNanim()
Determines total animal fertilizer (m_totalNanim) available at a farm.
Definition: farm.cpp:5643
OptimisingFarm * Find_neighbour_to_imitate()
Picks randomly a farmer to imitate/compare with. It chooses among neighbouring farmers with similar f...
Definition: farm.cpp:5380
vector< CropSort > m_winterCrops
Vector of structs containing pointers to winter crops.
Definition: farm.h:2198
double m_totalFUdemand
Farm's total demand for fodder (it is covered by growing fodder crops and/or purchasing fodder and th...
Definition: farm.h:2236
virtual void findFodderDemand()
Determines farm's total demand for fodder (m_totalFUdemand).
Definition: farm.cpp:5670
void findYieldLoss(CropOptimised *a_crop)
Determines the yield losses (CropOptimised::m_lossHerb, CropOptimised::m_lossFi, CropOptimised::m_tot...
Definition: farm.cpp:6200
int Get_farmRealID(void)
Definition: farm.h:2037
void Check_if_area_100()
Checks if the sum of crops' areaPercent is 100%.
Definition: farm.cpp:8060
void assignFixed()
Adds areas of fixed crops to the variable m_assigned. For each fixed crop it saves its area under var...
Definition: farm.cpp:6275
void Print_rotations(ofstream *ap_output_file)
Prints the content of a farm's m_rotation. Not used in ALMaSS crop mode.
Definition: farm.cpp:8389
double m_exp_profit
An expected farm's profit for a given year.
Definition: farm.h:2120
vector< double > m_previous_aggregated_yields
Vector of aggregated yields from previous years.
Definition: farm.h:2143
virtual void HandleEvents(void)
If there are events to carry out do this, and perhaps start a new crop.
Definition: farm.cpp:952
virtual void checkRestrictions()
Checks if the restrictions are fulfilled and corrects crops' areas if necessary.
Definition: farm.cpp:6410
void Match_crop_to_field(LE *a_field)
Finds a crop to be grown on a given field next year.
Definition: farm.cpp:9161
double m_exp_income
An expected farm's income at a farm in a given year.
Definition: farm.h:2124
vector< double > m_animals_numbers
Vector for storing numbers of animals at a farm in previous years (3).
Definition: farm.h:2150
virtual bool HerbicideTreat(LE *a_field, double, int a_days)
Carries out herbicide application. Saves information on each application for a given crop.
Definition: farmfuncs.cpp:1196
void createVariableCrops(int a_foobar)
Creates a list of pointers to all variable crops included in the optimisation and a list of pointers ...
Definition: farm.cpp:5579
void FarmLevelCalculation()
Calls functions determining farm level values before the initial optimisation.
Definition: farm.cpp:5613
void Set_main_goal(TTypeOfFarmerGoal a_goal)
Definition: farm.h:2057
CropOptimised * findCropByName_almass(string crop_name)
Returns a pointer to almass crop whose name is specified as the argument (ALMaSS crops mode).
Definition: farm.cpp:7770
vector< Livestock * > m_livestock
Vector of pointers to animals belonging to a farm.
Definition: farm.h:2181
void Translate_crops_to_almass()
Translates crops from Bedriftsmodel (original farm optimization model) to Almass crops....
Definition: farm.cpp:8075
virtual bool Spraying_fungins(TTypesOfVegetation a_tov_type)
Returns true if a farmer decided to treat a given crop with fung- and insecticides.
Definition: farm.cpp:5360
virtual void decreaseCrops(vector< CropSort >cropsToDecrease, double &howMuchToDecrease)
Decreases area of a crops by a specified number.
Definition: farm.cpp:7912
void findTotalArea()
Determines m_totalArea of a farm.
Definition: farm.cpp:5624
double m_actual_costs
Actual costs at a farm in a given year.
Definition: farm.h:2126
virtual void checkWinterRotation1()
Checks if the restriction on a winter rotation is fulfilled.
Definition: farm.h:2330
virtual ~OptimisingFarm()
Definition: farm.h:2033
int m_farmRealID
Farm's real ID number.
Definition: farm.h:2216
double m_exp_aggregated_yield
Expected aggregated yield at a farm in a given year.
Definition: farm.h:2134
void Print_FarmVariables(ofstream *ap_output_file)
Prints farm-level variables to a text file (one file for all farms).
Definition: farm.cpp:8045
double m_totalBI
Total amount of pesticides (sum of m_totalBIHerb and m_totalBIFi) which is planned to be applied at a...
Definition: farm.h:2252
double m_totalFUdemandBefore
Farm's total demand for fodder. [fodder units]
Definition: farm.h:2234
void findResponse(CropOptimised *a_crop, int a_foobar)
Determines the response (CropOptimised::m_resp) of a crop at a farm.
Definition: farm.cpp:6031
double m_totalArea
Total area of a farm. A sum of initial crop areas (if in bedriftsmodel, i.e. original farm optimizati...
Definition: farm.h:2224
OptimisingFarm * Get_Neighbour(int i)
Definition: farm.h:2050
vector< double > m_previous_satisfaction_levels
Vector of satisfaction levels in five previous years.
Definition: farm.h:2145
vector< AlmassCrop > Get_rotational_crops()
Definition: farm.h:2051
TTypesOfSoils m_soilType
Farm's soil type (sandy, clay, other).
Definition: farm.h:2212
vector< double > m_previous_incomes
Vector of incomes from previous years.
Definition: farm.h:2139
virtual void preventCashCrops()
Prevents small cattle farms from growing cash crops and maize silage.
Definition: farm.h:2293
virtual double Prob_multiplier()
Used when determining whether there should be a spraying event (i.e. pesticides application) or not....
Definition: farm.cpp:5372
int Get_almass_no(void)
Definition: farm.h:2039
void optimizeCrops(int a_foobar)
Carries out crop optimisation at a farm.
Definition: farm.cpp:5796
vector< AlmassCrop > m_rotational_crops
Vector of structs with almass type crops with positive areas in % (result of optimisation): includes ...
Definition: farm.h:2202
virtual void createCropsLists(int a_foobar)
Creates lists of crops.
Definition: farm.cpp:5570
int animals_no
Holds the number of animals in a farm at a particular day in a year (depends on a species).
Definition: farm.h:2154
double Get_actual_aggregated_yield()
Definition: farm.h:2054
void ActualProfit()
Function that determines actual crop yields and profit in a given year.
Definition: farm.cpp:8806
void randomizeCropList(vector< CropSort > &listToRandomize, string key)
Swaps randomly elements of the list holding same values of the key (according to which the list was p...
Definition: farm.cpp:7811
TTypesOfSoils Get_soilType(void)
Definition: farm.h:2035
void Make_almass_crops_vector()
Creates a vector storing crops with positive area. Used in ALMaSS crop mode.
Definition: farm.cpp:8269
void determineAreas_ha(vector< CropOptimised * >crops)
Determines areas of crops in ha.
Definition: farm.cpp:7967
double m_totalNt
Total amount of fertilizer purchased at a farm. [kg].
Definition: farm.h:2246
vector< double > m_previous_costs
Vector of costs from previous years.
Definition: farm.h:2141
vector< CropSort > m_rotationCrops
Vector of structs containing pointers to (winter) rotation crops.
Definition: farm.h:2196
int Get_decision_mode_counters(int index)
Definition: farm.h:2060
double m_totalGrooming
Total grooming planned at a farm.
Definition: farm.h:2254
double m_totalFUt
Fodder from trade (has to be purchased). [fodder units].
Definition: farm.h:2238
vector< CropSort > m_variableCrops2
Vector of structs containing pointers to crops which are not fixed and: in case of the winter rotatio...
Definition: farm.h:2190
void setRotationCropsAtMax()
Increases area of winter rotation crops to their max. allowed area.
double m_totalBIHerb
Total amount of herbicides which is planned to be applied at a farm. Expressed as a Treatment frequen...
Definition: farm.h:2248
int m_soilSubType
Farm's soil subtype. Defined only for cattle farms on sandy soil (0-bad, 1-good, 2-undefined).
Definition: farm.h:2218
virtual void InitiateManagement(void)
Kicks off the farm's management.
Definition: farm.cpp:5124
void Init(ofstream *ap_output_file)
Function carrying out the initial calculations at a farm level (including the initial optimisation).
Definition: farm.cpp:5294
vector< AlmassCrop > m_rotational_crops_copy
A copy of m_rotational_crops used when matching crops to fields.
Definition: farm.h:2204
double total(TTypesOfCropVariables variable_name)
Function for determining total values per farm after initial optimisation.
Definition: farm.cpp:7977
TTypesOfOptFarms Get_farmType(void)
Definition: farm.h:2034
double m_certainty_level
Farmer's certainty level.
Definition: farm.h:2112
TTypesOfFarmSize m_farmSize
Scale of the farm - business (size above 10 ha) or private (size below 10 ha).
Definition: farm.h:2214
void Set_Livestock(Livestock *p_lvs)
Definition: farm.h:2042
double m_Nanim
Amount of animal fertilizer available at a farm per hectar. [kg/ha].
Definition: farm.h:2232
OptimisingFarm * m_previously_imitated_neighbour
The neighbouring farmer whose crops might be copied in imitation and social comparison decision modes...
Definition: farm.h:2147
void Set_Neighbour(OptimisingFarm *farm)
Definition: farm.h:2048
void findNanim()
Determines amount of animal fertilizer per ha (m_Nanim) at a farm.
Definition: farm.cpp:5665
double m_totalCosts
Planned total costs of growing crops at a farm. [DKK].
Definition: farm.h:2260
bool force_deliberation
If set to true, a farm must use deliberation as a decision strategy.
Definition: farm.h:2152
void findMWeedControl(CropOptimised *a_crop)
Determines the optimal mechanical weed control means (CropOptimised::m_grooming, CropOptimised::m_hoe...
Definition: farm.cpp:6153
CropOptimised * Get_crop(int i)
Definition: farm.h:2040
TTypeOfFarmerGoal Get_main_goal()
Definition: farm.h:2058
int Get_NeighboursSize(void)
Definition: farm.h:2049
TTypesOfFarmSize Get_farmSize(void)
Definition: farm.h:2036
void Initialize(FarmManager *a_pfm)
Assigns to each farm its farm type, farm size, farm's real ID number, and soil type....
Definition: farm.cpp:5187
double m_assigned
Variable holding a value of area already reserved for certain crops at a farm. [0-100%].
Definition: farm.h:2242
double m_totalIncome
Planned total income from growing crops at a farm. [DKK].
Definition: farm.h:2262
OptimisingFarm(FarmManager *a_myfarmmanager, int a_No)
The constructor.
Definition: farm.cpp:5153
CropOptimised * findCropByName(string crop_name)
Returns a pointer to a crop whose name is specified as the argument (bedriftsmodel,...
Definition: farm.cpp:7762
vector< CropOptimised * > m_fixedCrops
Vector of pointers to fixed crops.
Definition: farm.h:2194
double m_totalNanim
Total animal fertilizer at a farm. A sum of Livestock::m_NanimUsable (from all types of livestock)....
Definition: farm.h:2230
double m_totalWeeding
Total manual weeding planned at a farm.
Definition: farm.h:2258
virtual void checkWinterCrops()
Checks if the restriction on a max. share of winter crops is fulfilled.
Definition: farm.h:2332
double Get_actual_profit()
Definition: farm.h:2053
vector< OptimisingFarm * > m_neighbours
Vector of pointers to the farms considered neighbours (fulfilling the neighbourship condition) of a g...
Definition: farm.h:2108
void Check_SG_and_CGG()
Modifies areas of SeedGrass1 and SeedGrass2, CloverGrassGrazed1 and CloverGrassGrazed2 to be even....
Definition: farm.cpp:5877
vector< AlmassCrop > m_crops_almass
Vector of structs with almass type crops with positive areas in % (result of optimisation).
Definition: farm.h:2200
Subclass of the NonAnimalFarm.
Definition: farm.h:2504
OptimisingOtherFarm(FarmManager *a_myfarmmanager, int a_No)
Definition: farm.cpp:5291
virtual ~OptimisingOtherFarm()
Definition: farm.h:2507
Subclass of the AnimalFarm.
Definition: farm.h:2433
void check_WRape_WBarley()
Checks if the restriction on winter rape and winter barley attachment is fulfilled and corrects crops...
Definition: farm.cpp:7380
OptimisingPigFarm(FarmManager *a_myfarmmanager, int a_No)
Definition: farm.cpp:5280
virtual void checkRestrictions()
Checks if the restrictions are fulfilled and corrects crops' areas if necessary.
Definition: farm.cpp:6457
virtual ~OptimisingPigFarm()
Definition: farm.h:2436
Subclass of the NonAnimalFarm.
Definition: farm.h:2495
virtual ~OptimisingPlantFarm()
Definition: farm.h:2498
OptimisingPlantFarm(FarmManager *a_myfarmmanager, int a_No)
Definition: farm.cpp:5287
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1161
OrganicCattle(FarmManager *a_manager)
Definition: farm.cpp:2038
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1149
OrganicPig(FarmManager *a_manager)
Definition: farm.cpp:2045
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1136
virtual void MakeStockFarmer(void)
Definition: farm.h:1139
OrganicPlant(FarmManager *a_manager)
Definition: farm.cpp:2052
Inbuilt special purpose farm type.
Definition: farm.h:1173
virtual void MakeStockFarmer(void)
Definition: farm.h:1176
PesticideTrialControl(FarmManager *a_manager)
Definition: farm.cpp:2059
Inbuilt special purpose farm type.
Definition: farm.h:1183
PesticideTrialToxicControl(FarmManager *a_manager)
Definition: farm.cpp:2067
virtual void MakeStockFarmer(void)
Definition: farm.h:1186
Inbuilt special purpose farm type.
Definition: farm.h:1193
virtual void MakeStockFarmer(void)
Definition: farm.h:1196
PesticideTrialTreatment(FarmManager *a_manager)
Definition: farm.cpp:2075
Base class for all population managers.
Definition: PopulationManager.h:424
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1360
UserDefinedFarm10(FarmManager *a_manager)
Definition: farm.cpp:2292
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1369
UserDefinedFarm11(FarmManager *a_manager)
Definition: farm.cpp:2299
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1378
UserDefinedFarm12(FarmManager *a_manager)
Definition: farm.cpp:2306
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1387
UserDefinedFarm13(FarmManager *a_manager)
Definition: farm.cpp:2313
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1396
UserDefinedFarm14(FarmManager *a_manager)
Definition: farm.cpp:2320
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1405
UserDefinedFarm15(FarmManager *a_manager)
Definition: farm.cpp:2327
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1414
UserDefinedFarm16(FarmManager *a_manager)
Definition: farm.cpp:2334
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1423
UserDefinedFarm17(FarmManager *a_manager)
Definition: farm.cpp:2342
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1432
UserDefinedFarm18(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2531
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1442
UserDefinedFarm19(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2536
Definition: farm.h:1279
UserDefinedFarm1(FarmManager *a_manager)
Definition: farm.cpp:2220
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1452
UserDefinedFarm20(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2541
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1462
UserDefinedFarm21(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2546
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1472
UserDefinedFarm22(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2551
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1482
UserDefinedFarm23(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2556
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1492
UserDefinedFarm24(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2561
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1502
UserDefinedFarm25(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2566
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1512
UserDefinedFarm26(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2571
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1522
UserDefinedFarm27(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2576
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1532
UserDefinedFarm28(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2581
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1542
UserDefinedFarm29(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2586
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1288
UserDefinedFarm2(FarmManager *a_manager)
Definition: farm.cpp:2228
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1552
UserDefinedFarm30(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2591
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1562
UserDefinedFarm31(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2596
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1572
UserDefinedFarm32(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2601
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1582
UserDefinedFarm33(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2606
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1592
UserDefinedFarm34(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2611
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1602
UserDefinedFarm35(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2616
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1297
UserDefinedFarm3(FarmManager *a_manager)
Definition: farm.cpp:2236
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1306
UserDefinedFarm4(FarmManager *a_manager)
Definition: farm.cpp:2244
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1315
UserDefinedFarm5(FarmManager *a_manager)
Definition: farm.cpp:2252
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1324
UserDefinedFarm6(FarmManager *a_manager)
Definition: farm.cpp:2260
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1333
UserDefinedFarm7(FarmManager *a_manager)
Definition: farm.cpp:2268
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1342
UserDefinedFarm8(FarmManager *a_manager)
Definition: farm.cpp:2276
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1351
UserDefinedFarm9(FarmManager *a_manager)
Definition: farm.cpp:2284
A farm that can have its rotation defined by the user at runtime.
Definition: farm.h:1268
UserDefinedFarm(const char *fname, FarmManager *a_manager)
Definition: farm.cpp:2349
virtual void InitiateManagement(void)
Kicks off the farm's management.
Definition: farm.cpp:1499
TTypeOfFarmerGoal
Definition: farm.h:435
@ tofg_profit
Definition: farm.h:436
@ tofg_environment
Definition: farm.h:438
@ tofg_Foobar
Definition: farm.h:439
@ tofg_yield
Definition: farm.h:437
PlantProtectionProducts
A list PPP names for tracking by the Pesticide class.
Definition: farm.h:421
@ ppp_6
Definition: farm.h:427
@ ppp_foobar
Definition: farm.h:432
@ ppp_10
Definition: farm.h:431
@ ppp_3
Definition: farm.h:424
@ ppp_7
Definition: farm.h:428
@ ppp_1
Definition: farm.h:422
@ ppp_8
Definition: farm.h:429
@ ppp_4
Definition: farm.h:425
@ ppp_9
Definition: farm.h:430
@ ppp_5
Definition: farm.h:426
@ ppp_2
Definition: farm.h:423
TTypesOfParameters
Definition: farm.h:371
@ top_Foobar
Definition: farm.h:389
@ top_BetaW
Definition: farm.h:388
@ top_PriceW
Definition: farm.h:378
@ top_AlfaW
Definition: farm.h:387
@ top_BetaG
Definition: farm.h:384
@ top_PriceFi
Definition: farm.h:375
@ top_AlfaG
Definition: farm.h:383
@ top_PriceHerb
Definition: farm.h:374
@ top_PriceLM
Definition: farm.h:373
@ top_AlfaFi
Definition: farm.h:381
@ top_AlfaHerb
Definition: farm.h:379
@ top_Subsidy
Definition: farm.h:372
@ top_BetaHerb
Definition: farm.h:380
@ top_PriceH
Definition: farm.h:377
@ top_BetaFi
Definition: farm.h:382
@ top_AlfaH
Definition: farm.h:385
@ top_PriceG
Definition: farm.h:376
@ top_BetaH
Definition: farm.h:386
TTypesOfCrops
Definition: farm.h:323
@ toc_PerGrassLow
Definition: farm.h:347
@ toc_GrassRot
Definition: farm.h:351
@ toc_OSCrops
Definition: farm.h:326
@ toc_CloverGrz
Definition: farm.h:357
@ toc_Oats
Definition: farm.h:325
@ toc_FruitTree
Definition: farm.h:360
@ toc_PerGrassNorm
Definition: farm.h:348
@ toc_OOilseed
Definition: farm.h:333
@ toc_SCerealG
Definition: farm.h:346
@ toc_WRye
Definition: farm.h:329
@ toc_Foobar
Definition: farm.h:367
@ toc_SCerealSil
Definition: farm.h:342
@ toc_ChrisTree
Definition: farm.h:362
@ toc_FodderBeet
Definition: farm.h:355
@ toc_Setaside
Definition: farm.h:352
@ toc_EnergyFor
Definition: farm.h:363
@ toc_PotatoFood
Definition: farm.h:338
@ toc_Triticale
Definition: farm.h:330
@ toc_WWheat
Definition: farm.h:328
@ toc_SugarBeet
Definition: farm.h:339
@ toc_Other
Definition: farm.h:366
@ toc_SBarley
Definition: farm.h:324
@ toc_OUncult
Definition: farm.h:354
@ toc_PeasSil
Definition: farm.h:343
@ toc_GrassSeed
Definition: farm.h:336
@ toc_WRape
Definition: farm.h:332
@ toc_SpringRape
Definition: farm.h:365
@ toc_SRape
Definition: farm.h:331
@ toc_GrassClover
Definition: farm.h:340
@ toc_GrassEnv2
Definition: farm.h:350
@ toc_OSpecCrops
Definition: farm.h:361
@ toc_WCerealSil
Definition: farm.h:345
@ toc_WBarley
Definition: farm.h:327
@ toc_OFodderBeet
Definition: farm.h:356
@ toc_Potato
Definition: farm.h:337
@ toc_OTriticale
Definition: farm.h:364
@ toc_Peas
Definition: farm.h:334
@ toc_OLSeedCut
Definition: farm.h:341
@ toc_Fruit
Definition: farm.h:359
@ toc_Veg
Definition: farm.h:358
@ toc_OLSeed
Definition: farm.h:335
@ toc_Uncult
Definition: farm.h:353
@ toc_GrassEnv1
Definition: farm.h:349
@ toc_MaizeSil
Definition: farm.h:344
TTypesOfOptFarms
Definition: farm.h:278
@ toof_Other
Definition: farm.h:279
@ toof_Cattle
Definition: farm.h:280
@ toof_Foobar
Definition: farm.h:283
@ toof_Plant
Definition: farm.h:281
@ toof_Pig
Definition: farm.h:282
TTypesOfCropVariables
Definition: farm.h:399
@ tocv_TotalLoss
Definition: farm.h:410
@ tocv_BI
Definition: farm.h:406
@ tocv_AreaPercent
Definition: farm.h:400
@ tocv_Income
Definition: farm.h:412
@ tocv_Hoeing
Definition: farm.h:408
@ tocv_Nt
Definition: farm.h:403
@ tocv_Grooming
Definition: farm.h:407
@ tocv_BIFi
Definition: farm.h:405
@ tocv_GM
Definition: farm.h:414
@ tocv_Costs
Definition: farm.h:413
@ tocv_N
Definition: farm.h:402
@ tocv_Savings
Definition: farm.h:415
@ tocv_Foobar
Definition: farm.h:416
@ tocv_BIHerb
Definition: farm.h:404
@ tocv_Weeding
Definition: farm.h:409
@ tocv_AreaHa
Definition: farm.h:401
@ tocv_Response
Definition: farm.h:411
TTypesOfLivestockParameters
Definition: farm.h:392
@ tolp_Foobar
Definition: farm.h:396
@ tolp_FUuKey
Definition: farm.h:395
@ tolp_Nusable
Definition: farm.h:394
@ tolp_AUKey
Definition: farm.h:393
TTypesOfFarmSize
Definition: farm.h:293
@ tofs_Business
Definition: farm.h:294
@ tofs_Foobar
Definition: farm.h:296
@ tofs_Private
Definition: farm.h:295
TTypesOfFarm
Definition: farm.h:222
@ tof_NoPesticideNoP
Definition: farm.h:237
@ tof_UserDefinedFarm19
Definition: farm.h:256
@ tof_OptimisingFarm
Definition: farm.h:273
@ tof_UserDefinedFarm2
Definition: farm.h:239
@ tof_AgroChemIndustryCerealFarm1
Definition: farm.h:233
@ tof_UserDefinedFarm5
Definition: farm.h:242
@ tof_OrganicPig
Definition: farm.h:227
@ tof_UserDefinedFarm34
Definition: farm.h:271
@ tof_PTrialControl
Definition: farm.h:229
@ tof_ConventionalPig
Definition: farm.h:224
@ tof_UserDefinedFarm33
Definition: farm.h:270
@ tof_ConvMarginalJord
Definition: farm.h:232
@ tof_UserDefinedFarm27
Definition: farm.h:264
@ tof_PTrialTreatment
Definition: farm.h:230
@ tof_PTrialToxicControl
Definition: farm.h:231
@ tof_ConventionalCattle
Definition: farm.h:223
@ tof_UserDefinedFarm9
Definition: farm.h:246
@ tof_UserDefinedFarm32
Definition: farm.h:269
@ tof_UserDefinedFarm13
Definition: farm.h:250
@ tof_UserDefinedFarm29
Definition: farm.h:266
@ tof_UserDefinedFarm17
Definition: farm.h:254
@ tof_UserDefinedFarm11
Definition: farm.h:248
@ tof_UserDefinedFarm7
Definition: farm.h:244
@ tof_UserDefinedFarm26
Definition: farm.h:263
@ tof_UserDefinedFarm30
Definition: farm.h:267
@ tof_UserDefinedFarm18
Definition: farm.h:255
@ tof_UserDefinedFarm24
Definition: farm.h:261
@ tof_UserDefinedFarm3
Definition: farm.h:240
@ tof_UserDefinedFarm15
Definition: farm.h:252
@ tof_AgroChemIndustryCerealFarm3
Definition: farm.h:235
@ tof_UserDefinedFarm31
Definition: farm.h:268
@ tof_UserDefinedFarm35
Definition: farm.h:272
@ tof_UserDefinedFarm20
Definition: farm.h:257
@ tof_NoPesticideBase
Definition: farm.h:236
@ tof_UserDefinedFarm6
Definition: farm.h:243
@ tof_UserDefinedFarm10
Definition: farm.h:247
@ tof_OrganicPlant
Definition: farm.h:228
@ tof_UserDefinedFarm16
Definition: farm.h:253
@ tof_UserDefinedFarm8
Definition: farm.h:245
@ tof_UserDefinedFarm12
Definition: farm.h:249
@ tof_UserDefinedFarm25
Definition: farm.h:262
@ tof_OrganicCattle
Definition: farm.h:226
@ tof_UserDefinedFarm23
Definition: farm.h:260
@ tof_UserDefinedFarm21
Definition: farm.h:258
@ tof_UserDefinedFarm28
Definition: farm.h:265
@ tof_ConventionalPlant
Definition: farm.h:225
@ tof_UserDefinedFarm4
Definition: farm.h:241
@ tof_UserDefinedFarm1
Definition: farm.h:238
@ tof_UserDefinedFarm22
Definition: farm.h:259
@ tof_AgroChemIndustryCerealFarm2
Definition: farm.h:234
@ tof_UserDefinedFarm14
Definition: farm.h:251
TTypesOfSoils
Definition: farm.h:286
@ tos_Foobar
Definition: farm.h:290
@ tos_Clay
Definition: farm.h:289
@ tos_Other
Definition: farm.h:288
@ tos_Sand
Definition: farm.h:287
vector< Hunter * > HunterList
Definition: farm.h:211
TTypeCropClassification
Definition: farm.h:213
@ tocc_Foobar
Definition: farm.h:217
@ tocc_Winter
Definition: farm.h:214
@ tocc_Spring
Definition: farm.h:215
@ tocc_Catch
Definition: farm.h:216
TTypesOfAnimals
Definition: farm.h:299
@ toa_Mink
Definition: farm.h:312
@ toa_DCow
Definition: farm.h:301
@ toa_MDuck
Definition: farm.h:318
@ toa_Deer
Definition: farm.h:311
@ toa_DCalf
Definition: farm.h:303
@ toa_Duck
Definition: farm.h:317
@ toa_MCattle
Definition: farm.h:305
@ toa_Turkey
Definition: farm.h:315
@ toa_So
Definition: farm.h:308
@ toa_Finisher
Definition: farm.h:309
@ toa_Piglet
Definition: farm.h:310
@ toa_MCalf
Definition: farm.h:304
@ toa_Foobar
Definition: farm.h:320
@ toa_Suckler
Definition: farm.h:302
@ toa_MHen
Definition: farm.h:314
@ toa_Goose
Definition: farm.h:316
@ toa_Sheep
Definition: farm.h:306
@ toa_Horse
Definition: farm.h:300
@ toa_EHen
Definition: farm.h:313
@ toa_Ostrich
Definition: farm.h:319
@ toa_Goat
Definition: farm.h:307
vector< unsigned > polylist
Definition: farm.h:207
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
Struct for storing ALMaSS crop type (TTypesOfVegetation) with a corresponding value (mainly crop area...
Definition: farm.h:580
double Number
Definition: farm.h:581
TTypesOfVegetation Tov
Definition: farm.h:582
A struct to hold the information required to trigger a farm event.
Definition: farm.h:464
TTypesOfVegetation m_event
Definition: farm.h:470
FarmEvent(TTypesOfVegetation a_event, LE *a_field, int a_todo, long a_run, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_nextcrop)
Definition: farm.h:474
bool m_lock
Definition: farm.h:465
LE * m_field
Definition: farm.h:472
bool m_first_year
Definition: farm.h:467
int m_todo
Definition: farm.h:469
int m_startday
Definition: farm.h:466
long m_run
Definition: farm.h:468
TTypesOfVegetation m_next_tov
Definition: farm.h:471
Struct used for storing data on pesticide usage throughout the whole simulation (one instance,...
Definition: farm.h:1923
TTypesOfVegetation Tov
Definition: farm.h:1924
double BI
Definition: farm.h:1927
double BIherb
Definition: farm.h:1925
double BIfi
Definition: farm.h:1926
Struct used for sorting crops.
Definition: farm.h:2161
CropOptimised * crop
Definition: farm.h:2163
double key
Definition: farm.h:2162
Struct used only in Bedriftsmodel crop type mode for creating m_rotation vector. Bool member used for...
Definition: farm.h:2173
TTypesOfVegetation Tov
Definition: farm.h:2175
bool taken
Definition: farm.h:2174
Struct redefining operator < - used for sorting crops.
Definition: farm.h:2167
bool operator()(CropSort a, CropSort b)
Definition: farm.h:2168
Used for storing permanent crop data for the farm rotation.
Definition: farm.h:448
TTypesOfVegetation Tov
Definition: farm.h:449
int Pct
Definition: farm.h:450
Used during saving farm/hunter information.
Definition: farm.h:493
int m_farmref
Definition: farm.h:494
int m_farmtype
Definition: farm.h:495
int m_areaopenfields
Definition: farm.h:500
int m_farmarable
Definition: farm.h:497
int m_openfields
Definition: farm.h:499
int m_nofields
Definition: farm.h:498
int m_NoHunters
Definition: farm.h:503
APoint m_farmvalid
Definition: farm.h:502
int m_farmsize
Definition: farm.h:496
APoint m_farmcentroid
Definition: farm.h:501
Definition: farm.h:442
bool m_present
Definition: farm.h:444
double m_amounts[ppp_foobar]
Definition: farm.h:443
Used for storing farmers field size vectors.
Definition: farm.h:454
int pct
Definition: farm.h:456
int index
Definition: farm.h:455
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
TTypesOfVegetation
Definition: tov_declaration.h:30